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

Allow custom exception handler for NotFoundException and Exception #3108

Closed
heruan opened this issue Dec 6, 2017 · 2 comments
Closed

Allow custom exception handler for NotFoundException and Exception #3108

heruan opened this issue Dec 6, 2017 · 2 comments

Comments

@heruan
Copy link
Member

heruan commented Dec 6, 2017

When building a structured app, I want to be able to use customize exception handlers routes for NotFoundException and Exception extending my own classes, not the default ones (e.g. NotFoundRoute).

Currently this is not possibile, it throws:

com.vaadin.server.InvalidRouteLayoutConfigurationException: Only one target for an exception should be defined. Found 'it.axians.oss.base.vaadin.routing.NotFoundRoute' and 'com.vaadin.router.RouteNotFoundError' for exception 'com.vaadin.router.NotFoundException'
@caalador
Copy link
Contributor

caalador commented Dec 7, 2017

So just to clarify what you would want is to have:
MyNotFoundException extends MyOwnExceptionHandler implements HasErrorParameter<NotFoundException> that would override/ignore the default RouteNotFoundError class.

Instead of the current hierarchical version where it's ok to override if you extend the default class. e.g. Register a child handler if parent registered or leave as is if child registered.
* If the target is not related to the registered handler then throw configuration exception as only one handler for each exception type is allowed.

@heruan
Copy link
Member Author

heruan commented Dec 7, 2017

I'd want my exception handlers to extends a custom component and I'm doing this for various exception and it works very well: only problem is for 404 and 500 error codes, whose handlers are required to extend the default one provided by Flow.

I didn't dive into the internals on how Flow currently choose the handler to use, but I'd expect it to look for an implementation of HasErrorParameter<E> and fallback to the default handlers if there are none.

@caalador caalador self-assigned this Dec 7, 2017
@pleku pleku added this to the 1.0.0.alpha14 milestone Dec 8, 2017
@pleku pleku closed this as completed Dec 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants