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

RouteParameters.getLong("param") should provide the parameter name in the exception message #9994

Closed
mvysny opened this issue Feb 9, 2021 · 3 comments · Fixed by #10716
Closed

Comments

@mvysny
Copy link
Member

mvysny commented Feb 9, 2021

Description of the bug / feature

When event.getRouteParameters().getLong("param") fails, it should provide the parameter name in the exception message

Minimal reproducible example

@Route("foo/:myparam/bar")
public class ExampleRoute extends VerticalLayout implements BeforeEnterObserver {
    @Override
    public void beforeEnter(BeforeEnterEvent event) {
        System.out.println(event.getRouteParameters().getLong("myparam").get());
    }
}

Expected behavior

The NumberFormatException should be wrapped in an IllegalArgumentException which should clearly state the parameter name.

Actual behavior

Current message doesn't contain the parameter name myparam

java.lang.NumberFormatException: For input string: "kvak"
	at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
	at java.base/java.lang.Long.parseLong(Long.java:692)
	at java.base/java.lang.Long.valueOf(Long.java:1144)
	at com.vaadin.flow.router.RouteParameters.getLong(RouteParameters.java:155)
	at org.vaadin.example.ExampleRoute.beforeEnter(Cicina.java:13)

Versions:

- Vaadin / Flow version: 14.5.0.alpha3
@mvysny mvysny changed the title When event.getRouteParameters().getLong("param") fails, it should provide the parameter name in the exception message When RouteParameters.getLong("param") fails, it should provide the parameter name in the exception message Feb 9, 2021
@mvysny mvysny changed the title When RouteParameters.getLong("param") fails, it should provide the parameter name in the exception message RouteParameters.getLong("param") should provide the parameter name in the exception message Feb 9, 2021
@pleku pleku added this to Needs triage in OLD Vaadin Flow bugs & maintenance (Vaadin 10+) via automation Feb 9, 2021
@pleku pleku moved this from Needs triage to New P2 in OLD Vaadin Flow bugs & maintenance (Vaadin 10+) Feb 9, 2021
@denis-anisimov denis-anisimov self-assigned this Apr 19, 2021
@denis-anisimov denis-anisimov moved this from Ready To Go to In progress in OLD Vaadin Flow ongoing work (Vaadin 10+) Apr 19, 2021
OLD Vaadin Flow ongoing work (Vaadin 10+) automation moved this from In progress to Done - pending release Apr 20, 2021
OLD Vaadin Flow bugs & maintenance (Vaadin 10+) automation moved this from New P2 to Closed Apr 20, 2021
@vaadin-bot
Copy link
Collaborator

This ticket/PR has been released with platform 19.0.6. For prerelease versions, it will be included in its final version.

@vaadin-bot
Copy link
Collaborator

This ticket/PR has been released with platform 14.6.0.rc1. For prerelease versions, it will be included in its final version.

@vaadin-bot
Copy link
Collaborator

This ticket/PR has been released with platform 14.5.5. For prerelease versions, it will be included in its final version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment