question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Exception handlers registration behavior

See original GitHub issue

Should Starlette raise an exception when there are exception handlers for 500 status code and for Exception class?

For instance, in this case, only one of those handlers will be called.

def handler_for_500(req, exc):
    ...

def handler_for_exception(req, exc):
    ...

app = Starlette(
    exception_handlers={
        500: handler_for_500,
        Exception: handler_for_exception,
    }
)

So my question - is this expected behavior or it is a bug?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
aminalaeecommented, Dec 15, 2021

Sorry I didn’t explain that clearly. What I meant is that we could consider a full stop with a RuntimeError, or have a warning saying already have an error_handler and ignore it.

Totally agree, let’s wait for feedback.

0reactions
Kludexcommented, Dec 15, 2021

Or we could also set the first error_handlder and ignore any other after that.

That’s just transferring the problem.

I don’t think we do any sacrifice doing the check, as we’ll run it once, but… Is it necessary?

Well, it’s been a year, let’s ask the issuer. @uriyyo after more than a year, what are your thoughts about this issue? Do you think doing the check is still necessary?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Chapter 20: Exception Handling Frameworks - Micro Focus
An exception method enables you to handle an error raised by an Object COBOL object in the way that best suits the application....
Read more >
Complete Guide to Exception Handling in Spring Boot
This article showcases various ways to handle exceptions in a Spring Boot Application.
Read more >
Customizing exception handlers - IBM
User-written exception handlers permit you to customize exception handling for certain conditions. You can register a user-written exception handler for the ...
Read more >
Exception Handling in Spring MVC
If the same exception can be handed in more than one way, you may not get the behavior you wanted.
Read more >
Exception handling - Wikipedia
In computing and computer programming, exception handling is the process of responding to the occurrence of exceptions – anomalous or exceptional conditions ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found