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

improving logging #20

Merged
merged 1 commit into from
Jan 11, 2024
Merged
Changes from all 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
38 changes: 30 additions & 8 deletions appetiser.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import subprocess

from app.json_utils import (
extract_process_kwargs,
extract_response_items,
Expand Down Expand Up @@ -50,14 +52,34 @@ def ping():
def convert():
json_data = flask.request.get_json()
appetiser.logger.info('Processing request data: %s', json_data)
result = process(**extract_process_kwargs(json_data))
proto_reponse = {
**result,
**extract_response_items(json_data)
}
response = add_iiif_info_json(proto_reponse)
appetiser.logger.info('Response: %s', json_data)
return flask.jsonify(response)
try:
result = process(**extract_process_kwargs(json_data))
proto_reponse = {
**result,
**extract_response_items(json_data)
}
response = add_iiif_info_json(proto_reponse)
appetiser.logger.info('Response: %s', json_data)
return flask.jsonify(response)
except FileNotFoundError as fileError:
appetiser.logger.exception('Error: %s', fileError)
return flask.jsonify(
status='file not found',
message=str(fileError)
), 400
except subprocess.CalledProcessError as subprocess_error:
appetiser.logger.exception('Error: %s', subprocess_error.stderr)
return flask.jsonify(
status='kakadu error',
message=str(subprocess_error.stderr)
donaldgray marked this conversation as resolved.
Show resolved Hide resolved
), 500
except Exception as general_error:
appetiser.logger.exception('Error: %s', general_error)

return flask.jsonify(
status='server error',
message=str(general_error)
), 500


if __name__ == '__main__':
Expand Down
Loading