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

Make exception default messages consistent #46

Open
idg10 opened this issue Jun 25, 2020 · 0 comments
Open

Make exception default messages consistent #46

idg10 opened this issue Jun 25, 2020 · 0 comments

Comments

@idg10
Copy link
Contributor

idg10 commented Jun 25, 2020

Some of our exceptions, e.g. OpenApiBadRequestException define a default message in their zero-arguments constructor. Some, e.g. OpenApiUnauthorizedException, do not.

We should be consistent about this. That probably means adding messages in the cases where they are not present.

This came up in a project, and @mwadams had this comment:

We don't typically provide a message for an Unauthorized exception, do we? Why would we?

In most cases we don't really expect this exception to be reported. Its purpose is to provide a way for us to signal to Menes that we need to bail out of processing and fail, without being obliged to unwind the entire call stack manually and return a suitable response code. So typically, application code throws this, and Menes catches it without looking at the message and produces a suitable response.

Since the exception will be handled without ever looking at the message, there is arguably no need for a message. However, there are various debug and diagnostic scenarios in which an exception might be inspected, so as a general rule it's good practice to have a meaningful Message even if in most cases you don't expect it to be used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant