Skip to content

Commit

Permalink
Merge pull request #62 from geoadmin/develop
Browse files Browse the repository at this point in the history
New Release v1.4.1 - #patch
  • Loading branch information
ltshb authored Jan 31, 2023
2 parents 1f9c521 + 2b0b5aa commit 8efe4c5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
32 changes: 26 additions & 6 deletions app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,37 @@ def add_cors_and_cache_header(response):
@app.errorhandler(Exception)
def handle_exception(error):
if isinstance(error, HTTPException):
logger.error(
'Request failed code=%d description=%s',
error.code,
error.description
)
if error.code == 500:
logger.exception(
'Request failed code=%d description=%s',
error.code,
error.description,
extra={'response': {
"status_code": error.code,
}}
)
else:
logger.error(
'Request failed code=%d description=%s',
error.code,
error.description,
extra={'response': {
"status_code": error.code,
}}
)

if 'Accept' in request.headers and 'text/html' in request.headers[
'Accept']:
return error
return make_error_msg(error.code, error.description)

logger.exception('Unexpected exception: %s', error)
logger.exception(
'Unexpected exception: %s',
error,
extra={'response': {
"status_code": 500,
}}
)
if 'Accept' in request.headers and 'text/html' in request.headers['Accept']:
return error
return make_error_msg(500, "Internal server error, please consult logs")
Expand Down
4 changes: 1 addition & 3 deletions app/helpers/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ def get_s3_file(wmts_path, etag=None):
)
return None, None
except (http.client.HTTPException, socket_timeout) as error:
logger.error(
'Failed to get S3 file %s: %s', wmts_path, error, exc_info=True
)
logger.error('Failed to get S3 file %s: %s', wmts_path, error)
return None, None
finally:
if http_client:
Expand Down

0 comments on commit 8efe4c5

Please sign in to comment.