graphsense / graphsense-REST

A REST service for accessing cryptocurrency data stored in Apache Cassandra.
MIT License
10 stars 8 forks source link

Improve Error Handling in REST Interface #92

Closed soad003 closed 11 months ago

soad003 commented 1 year ago

Global error handling is currently done in the auto generated (via a template) controllers where uncatched errors are converted into http responses (e.g. https://github.com/graphsense/graphsense-REST/blob/416c96dc37ea7f1af8d88c9e6ac00d462780e4d9/openapi_server/controllers/addresses_controller.py#L74-L90).

Some exception types get special treatment like value errors and Runtime errors. They are simply ignored and a generic http status code is returned to the client. Only a stacktrace is printed to the console log and no other notifications are set up. Given that we only get notified on error logs via the python logging facility those kinds of errors usually go unnoticed.

soad003 commented 11 months ago

The old logic reused generic exception types for signaling very specific events to the user:

Since these exception types are very generic and used by libs etc. in an uncontrollable fashion, some errors gone unnoticed (where only reported to the user). As a remedy we introduced new custom exceptions to handle the two exception cases we want to explicitly push back to the user.

This should avoid missing relevant errors in the REST interface.