diff options
Diffstat (limited to 'wqflask')
-rw-r--r-- | wqflask/wqflask/marker_regression/exceptions.py | 13 | ||||
-rw-r--r-- | wqflask/wqflask/templates/mapping_error.html | 7 | ||||
-rw-r--r-- | wqflask/wqflask/views.py | 10 |
3 files changed, 25 insertions, 5 deletions
diff --git a/wqflask/wqflask/marker_regression/exceptions.py b/wqflask/wqflask/marker_regression/exceptions.py new file mode 100644 index 00000000..8c7e822b --- /dev/null +++ b/wqflask/wqflask/marker_regression/exceptions.py @@ -0,0 +1,13 @@ +"""Mapping Exception classes.""" + +class NoMappingResultsError(Exception): + "Exception to raise if no results are computed." + + def __init__(self, trait, dataset, mapping_method): + self.trait = trait + self.dataset = dataset + self.mapping_method = mapping_method + self.message = ( + f"The mapping of trait '{trait}' from dataset '{dataset}' using " + f"the '{mapping_method}' mapping method returned no results.") + super().__init__(self.message, trait, mapping_method) diff --git a/wqflask/wqflask/templates/mapping_error.html b/wqflask/wqflask/templates/mapping_error.html index 963bf7d6..8364af3c 100644 --- a/wqflask/wqflask/templates/mapping_error.html +++ b/wqflask/wqflask/templates/mapping_error.html @@ -9,7 +9,12 @@ {%if error:%} <p> The following error was raised<br /><br /> - {{error.args[0]}}<br /><br /> + <dl> + <dt>Error message</dt> + <dd>{{error.args[0]}}</dd> + <dt>Error Type</dt> + <dd>{{error_type}}</dd> + </dl> </p> <p> Please contact Zach Sloan (zachary.a.sloan@gmail.com) or Arthur Centeno diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index ee0cd582..88dd31ba 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -46,6 +46,7 @@ from wqflask.external_tools import send_to_webgestalt from wqflask.external_tools import send_to_geneweaver from wqflask.comparison_bar_chart import comparison_bar_chart from wqflask.marker_regression import run_mapping +from wqflask.marker_regression.exceptions import NoMappingResultsError from wqflask.marker_regression import display_mapping_results from wqflask.network_graph import network_graph from wqflask.correlation.show_corr_results import set_template_vars @@ -720,10 +721,11 @@ def mapping_results_page(): try: template_vars = run_mapping.RunMapping(start_vars, temp_uuid) if template_vars.no_results: - rendered_template = render_template("mapping_error.html") - return rendered_template - except FileNotFoundError as fnfe: - rendered_template = render_template("mapping_error.html", error=fnfe) + raise NoMappingResultsError( + start_vars["trait_id"], start_vars["dataset"], start_vars["method"]) + except Exception as exc: + rendered_template = render_template( + "mapping_error.html", error=exc, error_type=type(exc).__name__) return rendered_template if not template_vars.pair_scan: |