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

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

Open
TOFarmer opened this issue Feb 6, 2021 · 1 comment · May be fixed by #47
Open

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

TOFarmer opened this issue Feb 6, 2021 · 1 comment · May be fixed by #47
Labels
Feature Issues or MRs that add, improve or maintain features Priority: 2 NORMAL: A task which is not critical and should be addressed when there are no higher priority issue

Comments

@TOFarmer
Copy link
Contributor

TOFarmer commented Feb 6, 2021

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 TOFarmer added the Feature Issues or MRs that add, improve or maintain features label Feb 6, 2021
@TOFarmer TOFarmer linked a pull request Feb 6, 2021 that will close this issue
4 tasks
@TOFarmer TOFarmer added the Priority: 2 NORMAL: A task which is not critical and should be addressed when there are no higher priority issue label Feb 8, 2021
@TOFarmer
Copy link
Contributor Author

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

  • If invalid content (i.e., content which cannot be deserialised within SAL) is sent as the JSON when using POST, an InvalidRequest('Could not de-serialise content.') is raised.
  • However if the content is valid but is not a Branch or DataObject, the InvalidRequest message is 'Content does not describe a Branch or DataObject'.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Issues or MRs that add, improve or maintain features Priority: 2 NORMAL: A task which is not critical and should be addressed when there are no higher priority issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant