calpoly-csai / api

Official API for the NIMBUS Voice Assistant accessible via HTTP REST protocol.
https://nimbus.api.calpolycsai.com/
GNU General Public License v3.0
9 stars 4 forks source link

Updates to error handling. #200

Closed snekiam closed 4 years ago

snekiam commented 4 years ago

Added question to error handler. Added get_question method to get the current question from the request object. Initiate a rollback for all exceptions, since we don't know what has succeeded/failed, and we could be in a bad state.

What's New?

This refactors the way we extract a question from a request into a function, with a BadRequest being raised when we are not able to extract the question.

Fixes #197 (partially). We should also retry questions that fail, but that's not in this PR.

Type of change (pick-one)

How Has This Been Tested?

Killed network connection to mysql to cause broken sessions. These were cleaned up correctly after reconnecting to the internet.

Checklist (check-all-before-merge)

formatting help: - [x] means "checked' and - [ ] means "unchecked"

sonarcloud[bot] commented 4 years ago

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication