diff options
Diffstat (limited to 'uploader/genotypes')
-rw-r--r-- | uploader/genotypes/views.py | 22 |
1 files changed, 5 insertions, 17 deletions
diff --git a/uploader/genotypes/views.py b/uploader/genotypes/views.py index 9f08ca6..0821eca 100644 --- a/uploader/genotypes/views.py +++ b/uploader/genotypes/views.py @@ -1,5 +1,4 @@ """Views for the genotypes.""" -from requests.models import Response from MySQLdb.cursors import DictCursor from flask import (flash, request, @@ -14,6 +13,7 @@ from uploader.oauth2.client import oauth2_post from uploader.authorisation import require_login from uploader.db_utils import database_connection from uploader.species.models import all_species, species_by_id +from uploader.monadic_requests import make_either_error_handler from uploader.request_checks import with_species, with_population from uploader.datautils import safe_int, order_by_family, enumerate_sequence from uploader.population.models import (populations_by_species, @@ -186,21 +186,6 @@ def create_dataset(species: dict, population: dict, **kwargs):# pylint: disable= species_id=species["SpeciesId"], population_id=population["Id"])) - def __fail__(error): - msg = "There was an error creating the genotype dataset." - if issubclass(type(error), Exception): - app.logger.debug("\n\n%s (Exception)\n\n", msg, exc_info=True) - raise error - if issubclass(type(error), Response): - try: - _data = error.json() - except Exception as _exc: - raise Exception(error.content) from _exc - raise Exception(_data) - - app.logger.debug("\n\n%s\n\n", msg) - raise Exception(error) - return oauth2_post( "auth/resource/genotypes/create", json={ @@ -213,4 +198,7 @@ def create_dataset(species: dict, population: dict, **kwargs):# pylint: disable= "dataset_shortname": form["geno-dataset-shortname"], "public": "on" } - ).either(__fail__, __success__) + ).either( + make_either_error_handler( + "There was an error creating the genotype dataset."), + __success__) |