I think this is good, but review would be greatly appreciated
Branch includes changes to allow generic error handling, presumably for all cases. In the SQL database, questions and their stacktraces are stored in the ErrorLog table. This error catching much more elegant. Caught stacktraces are still printed into stdout also.
Changes include:
Added handle_all_errors() function in flask_api.py
Catches all exceptions
Maintains previous functionality in OperationalError
Calls function to log error to database, in table (ErrorLog)
Adding log_error() function in flask_api.py
Logs stacktrace to database.
takes optional question field, as to provide more error context
Added new Entity file called ErrorLog
ErrorLog fields include (id, question, stacktrace, timestamp)
added necessary fields to Enity/ExcpectedKeys.py
Added format_error_log() to database_wrapper.py
allows ErrorLog, to use timestamp without raising a BadDictionaryKeyError
Added necessary imports to files
Fixes #182
Type of change (pick-one)
[ ] Bug fix (non-breaking change which fixes an issue)
[x] New feature (non-breaking change which adds functionality)
[ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
[ ] This change requires a documentation update
How Has This Been Tested?
I have seen correct ErrorLogs in the SQL database, after running:
What's New?
I think this is good, but review would be greatly appreciated
Branch includes changes to allow generic error handling, presumably for all cases. In the SQL database, questions and their stacktraces are stored in the
ErrorLog
table. This error catching much more elegant. Caught stacktraces are still printed into stdout also.Changes include:
Added
handle_all_errors()
function in flask_api.pyOperationalError
Adding
log_error()
function in flask_api.pyAdded new Entity file called ErrorLog
Added
format_error_log()
to database_wrapper.pyAdded necessary imports to files
Fixes #182
Type of change (pick-one)
How Has This Been Tested?
I have seen correct ErrorLogs in the SQL database, after running:
curl --location --request POST 'localhost:8080/ask' --header 'Content-Type: application/json' --data-raw '{ "question": "When CPE 233?" }'
Which caused a KeyError in
nimbus.answer_question(question)
I have also tested with functioning requests
Checklist (check-all-before-merge)
formatting help:
- [x]
means "checked' and- [ ]
means "unchecked"[ ] I documented my code according to the Google Python Style Guide
[ ] I ran
./build_docs.sh
and the docs look fine[ ] I ran
./type_check.sh
and got no errors[ ] I ran
./format.sh
because it automatically cleans my code for me 😄[ ] I ran
./lint.sh
to check for what "format" missed[ ] I added my tests to the
/tests
directory[ ] I ran
./run_tests.sh
and all the tests pass