Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format backend error msg #626

Merged
merged 18 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cdci_data_analysis/analysis/instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ def run_query(self, product_type,
'please use "provide feedback" button below. We would greatly appreciate it!\n\n'
'This additional information might help:\n\n'
)
e_message = f'Instrument: {self.name}, product: {product_type} failed!\n'
e_message = f'Instrument: {self.name}, product: {product_type}\n'
query_out.set_failed(product_type,
message=message,
e_message=e_message,
Expand Down
48 changes: 23 additions & 25 deletions cdci_data_analysis/analysis/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@


import logging
import os
import time as _time
import json
from collections import OrderedDict

import sentry_sdk
import decorator
import traceback
import numpy as np


from .parameters import (Parameter,
ParameterGroup,
ParameterRange,
from .parameters import (Parameter,
ParameterGroup,
ParameterRange,
ParameterTuple,
Name,
Angle,
Expand All @@ -40,15 +40,15 @@
DetectionThreshold,
Float,
TimeDelta,

# these are not used here but wildcard-imported from this module by integral plugin
SpectralBoundary,
Integer
)
from .products import SpectralFitProduct, QueryOutput, QueryProductList, ImageProduct
from .io_helper import FilePath
from .exceptions import RequestNotUnderstood, UnfortunateRequestResults, BadRequest, InternalError
import traceback
from .exceptions import RequestNotUnderstood, InternalError
from ..flask_app.sentry import sentry
Fixed Show fixed Hide fixed

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -452,7 +452,6 @@
debug_message=debug_message)

except Exception as e:
sentry_sdk.capture_exception(e)
raise InternalError(f"unexpected error while testing communication with {instrument}, {e!r}")

status = query_out.get_status()
Expand Down Expand Up @@ -583,26 +582,25 @@
raise

except Exception as e:
# TODO: could we avoid these? they make error tracking hard
# TODO we could use the very same approach used when test_communication fails
logger.exception("failed to get query products")
internal_error_message = "Error when getting query products"
# e_message = f"{internal_error_message} (instrument: {instrument.name}, product: {self.name}):\n{repr(e)}"
#
# if hasattr(e, 'debug_message') and e.debug_message is not None:
# debug_message = e.debug_message
# else:
# debug_message = 'no exception default debug message'
Fixed Show fixed Hide fixed

#status=1
job.set_failed()
if os.environ.get('DISPATCHER_DEBUG', 'yes') == 'yes':
raise
exception_message = getattr(e, 'message', '')
e_message = f'Failed when getting query products for job {job.job_id}:\n{exception_message}'
messages['debug_message'] = repr(e) + ' : ' + getattr(e, 'debug_message', '')

query_out.set_failed('get_query_products found job failed',
logger=logger,
sentry_dsn=sentry_dsn,
excep=e,
e_message=e_message,
debug_message=messages['debug_message'])
# TODO to use this approach when we will refactor the handling of exceptions
# raise InternalError(e_message)
# if os.environ.get('DISPATCHER_DEBUG', 'yes') == 'yes':
# raise
# query_out.set_failed('get_query_products',
# logger=logger,
# excep=e,
# e_message=e_message,
# debug_message=debug_message)

raise InternalError(internal_error_message)

logger.info('--> data_server_query_status %d' % query_out.get_status())
logger.info('--> end product query ')
Expand Down
Loading