Skip to content

Commit

Permalink
Merge pull request #729 from oda-hub/dedicated-exception-product-proc…
Browse files Browse the repository at this point in the history
…essing

Dedicated exception product processing
  • Loading branch information
burnout87 authored Jan 14, 2025
2 parents 718ff2d + 2980a6c commit bb62f68
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
6 changes: 6 additions & 0 deletions cdci_data_analysis/analysis/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ class RequestNotUnderstood(BadRequest):
"""


class ProductProcessingError(RuntimeError):
"""
For an error in the post-processing, caused by the user's request.
"""


class RequestNotAuthorized(BadRequest):
def __init__(self, message, debug_message=''):
self.debug_message = debug_message
Expand Down
6 changes: 5 additions & 1 deletion cdci_data_analysis/analysis/instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
from .queries import ProductQuery, SourceQuery, InstrumentQuery
from .io_helper import upload_file, upload_files_request

from .exceptions import RequestNotUnderstood, RequestNotAuthorized, InternalError
from .exceptions import RequestNotUnderstood, RequestNotAuthorized, InternalError, ProductProcessingError
from ..flask_app.sentry import sentry

from oda_api.api import DispatcherAPI, RemoteException, Unauthorized, DispatcherException, DispatcherNotAvailable, UnexpectedDispatcherStatusCode, RequestNotUnderstood as RequestNotUnderstoodOdaApi
Expand Down Expand Up @@ -480,6 +480,10 @@ def run_query(self, product_type,
except RequestNotUnderstood as e:
logger.warning("bad request from user, passing through: %s", e)
raise
except ProductProcessingError as e:
logger.warning("error in the post processing of the products to fail, passing through: %s", e)
query_out.set_status(1, message="Error during the products post processing",
error_message=str(e))
except InternalError as e:
if hasattr(e, 'message') and e.message is not None:
message = e.message
Expand Down
6 changes: 5 additions & 1 deletion cdci_data_analysis/analysis/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
)
from .products import SpectralFitProduct, QueryOutput, QueryProductList, ImageProduct
from .io_helper import FilePath
from .exceptions import RequestNotUnderstood, InternalError
from .exceptions import RequestNotUnderstood, InternalError, ProductProcessingError

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -614,6 +614,10 @@ def get_query_products(self,
logger.error("passing request issue: %s", e)
raise

except ProductProcessingError as e:
logger.error("product processing error: %s", e)
raise

except Exception as e:
logger.exception("failed to get query products")
internal_error_message = "Error when getting query products"
Expand Down

0 comments on commit bb62f68

Please sign in to comment.