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

Enhancement: Add class and funcion name to ImproperlyConfiguredExceptions #3548

Open
rafalkrupinski opened this issue Jun 6, 2024 · 4 comments
Labels
Enhancement This is a new feature or request

Comments

@rafalkrupinski
Copy link
Contributor

rafalkrupinski commented Jun 6, 2024

Summary

When you forget to add a type annotation in a route handler function, Litestar raises ImproperlyConfiguredException but neither the stack trace, nor the message shows which function or method is in error.

If the annotation were checked in @get decorators, the stack trace would let you find the line with the problem. If that's impossible, the exception should at least show function name, and the class in case of methods.

I volunteer to add function name in _validate_handler_function().

Basic Example

No response

Drawbacks and Impact

No response

Unresolved questions

No response


Note

While we are open for sponsoring on GitHub Sponsors and
OpenCollective, we also utilize Polar.sh to engage in pledge-based sponsorship.

Check out all issues funded or available for funding on our Polar.sh dashboard

  • If you would like to see an issue prioritized, make a pledge towards it!
  • We receive the pledge once the issue is completed & verified
  • This, along with engagement in the community, helps us know which features are a priority to our users.
Fund with Polar
@rafalkrupinski rafalkrupinski added the Enhancement This is a new feature or request label Jun 6, 2024
@euri10
Copy link
Contributor

euri10 commented Jun 6, 2024

I definitely +1 this : I found that when switching from another framework, sometimes you make big refactors, forget some stuff and get hit by that and it's hard to find where you made the mistakes as you just changed too many things, this would definitly make the process smoother.
There are obviouly other cases for that, but this one comes to mind :)

@rafalkrupinski
Copy link
Contributor Author

when switching from another framework

That's exactly where I'm coming from

@euri10
Copy link
Contributor

euri10 commented Jun 6, 2024

I should have listed them, but there were other cases where this ImproperlyConfiguredException popped up in case of big refactors, and wasn't too useful because of the lack of more granular info. Would that be a good time to list where they're used and maybe investigate if providing more info would make sense ?
Anyways a goo 1st step would be this, thanks for raising it.

@provinzkraut
Copy link
Member

Would that be a good time to list where they're used and maybe investigate if providing more info would make sense ?

Yeah, absolutely. I think we can generally improve a lot of our error messages with more details to make them more useful, but it's going to be a longer process I think. Incremental PRs are definitely welcome there! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement This is a new feature or request
Projects
None yet
Development

No branches or pull requests

3 participants