tighten up error reporting (#1269)

* black reformat

* tighten up error reporting

* lint

* fine tuning

* additional improvements in exception handling

* lint

* include exception and traceback in log

* fix typo
This commit is contained in:
Bruce Martin
2020-03-22 09:55:47 -07:00
committed by GitHub
parent 8180be83b8
commit db7a485796
9 changed files with 124 additions and 129 deletions
+6 -7
View File
@@ -11,7 +11,6 @@ from server.common.errors import AnnotationsError, OntologyLoadFailure
from server.common.utils import series_to_schema
import fsspec
import fastobo
import traceback # use built-in formatter for SyntaxError
from flask import session
from abc import ABCMeta, abstractmethod
@@ -39,14 +38,13 @@ class Annotations(metaclass=ABCMeta):
self.ontology_data = names
except FileNotFoundError as e:
raise OntologyLoadFailure(f"Unable to find OBO ontology path: {path}") from e
raise OntologyLoadFailure("Unable to find OBO ontology path") from e
except SyntaxError as e:
msg = "".join(traceback.format_exception_only(SyntaxError, e))
raise OntologyLoadFailure(msg) from e
raise OntologyLoadFailure("Syntax error loading OBO ontology") from e
except Exception as e:
raise OntologyLoadFailure(f"Error loading OBO file {path}") from e
raise OntologyLoadFailure("Error loading OBO file") from e
def get_schema(self, data_adaptor):
labels = self.read_labels(data_adaptor)
@@ -124,8 +122,9 @@ class AnnotationsLocalFile(Annotations):
if fname == self.last_fname:
return self.last_labels
else:
labels = pd.read_csv(fname, dtype="category",
index_col=0, header=0, comment="#", keep_default_na=False)
labels = pd.read_csv(
fname, dtype="category", index_col=0, header=0, comment="#", keep_default_na=False
)
# update the cache
self.last_fname = fname
self.last_labels = labels