simple-access-layer / source

The core repository of the Simple Access Layer.
https://simple-access-layer.github.io/documentation/
European Union Public License 1.2
2 stars 6 forks source link

Enable custom exception messages to be raised from SAL Server #46

Open TOFarmer opened 3 years ago

TOFarmer commented 3 years ago

Description

The Flask implementation of the SAL server relies on all exception types (and their messages) being defined when the server is initialised. This means that context specific messages (i.e. origin of the exception) cannot be returned to the client.

Suggested fix

Remove the server error_map and subclass flask_restful.Api to provide the ability to return custom exception messages.

Additional context

Although commonly a generic exception message (i.e. NodeNotFound: The supplied path does not point to a valid node.) will be sufficient for the client, occasionally additional context will be beneficial. For example, if the SAL server is interacting with a backend with a large number of exception types, there will be a many-to-one mapping to SAL exception types; in this instance being able to communicate the specific backend error message to the user could be useful.

TOFarmer commented 3 years ago

Another example of when this would be useful already exists when using POST:

In the current handling of exception neither or these messages would be passed to the user.