Skip to content

Conversation

@taion
Copy link
Contributor

@taion taion commented Nov 1, 2018

Fixes #2778

cc @ThiefMaster

This follows my last proposal in #2778 (comment).

@garenchan
Copy link
Contributor

Like you, I think the current implementation is a bit confusing.

But at least we can get the original error in the handler. This is useful for both logging and troubleshooting errors. But your solution doesn't take this into account.

@taion
Copy link
Contributor Author

taion commented Nov 12, 2018

Perhaps InternalServerError should be tagged with the original error.

Note, though, that the implementation above will forward the original error when the error handler is installed on 500.

@garenchan
Copy link
Contributor

garenchan commented Nov 12, 2018

I'm sorry to have misunderstood your solution. I think a test case for the handler of InternalServerError can help us understand your solution more easily.

@taion
Copy link
Contributor Author

taion commented Nov 12, 2018

This assertion is actually already present in

assert client.get('/keyerror').data == b'KeyError'
.

@garenchan
Copy link
Contributor

Oh, I see. I only read the codes in your patch. Please forgive me for wasting your precious time!

@taion
Copy link
Contributor Author

taion commented Nov 12, 2018

I mean, now that you mention it, though, I do think it would be a better API if InternalServerError had some reference to the actual original exception. That would likely constitute a breaking API change, though, whereas this might just barely be okay.

@garenchan
Copy link
Contributor

Yes, I quite agree with you.

Perhaps InternalServerError should be tagged with the original error.

@taion

This comment has been minimized.

@davidism
Copy link
Member

davidism commented Jun 19, 2019

While I understand the results of this, it's making the code harder to follow for me. Based on previous discussions in PRs that led to where we are now, it seems that it was intended that 500 and InternalServerError were aliases that behave the same way.

Instead, based on your discussions, I went the other direction and made it consistent. 500 and InternalServerError handlers always received InternalServerError, and also add an original_exception attribute. While this could result in some less-specific generic error messages if an application with the old behavior upgrades, I think the behavior becoming easier to reason about is worth it.

Thanks for discussing and working on this! Closing in favor of #3266

@davidism davidism closed this Jun 19, 2019
@taion taion deleted the handle-internal-server-error branch June 21, 2019 02:38
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Registered error handler (using register_error_handler) processes inappropriate exceptions

4 participants