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.

Status returned by HasErrorParameter#setErrorParameter is ignored.

See original GitHub issue

Description of the bug

I just downloaded sample project from start.vaadin.com and added RouteNotFoundView almost same as in documentation.

public class RouteNotFoundView extends Div implements HasErrorParameter<NotFoundException> {
    @Override
    public int setErrorParameter(BeforeEnterEvent event, ErrorParameter<NotFoundException> parameter) {
        getElement().setText("Cannot not navigate to '"
                + event.getLocation().getPath()
                + "'");
        return HttpServletResponse.SC_NOT_FOUND;
       }
    }

But it still returns HTTP status 200 and ignores HttpServletResponse.SC_NOT_FOUND

$ wget http://localhost:8080/notFound                                                                                                                        
--2022-04-05 14:13:51--  http://localhost:8080/notFound
Resolving localhost (localhost)... ::1, 127.0.0.1
Connecting to localhost (localhost)|::1|:8080... connected.
HTTP request sent, awaiting response... 200 
Length: 3665 (3,6K) [text/html]
Saving to: ‘notFound’

notFound                                        100%[====================================================================================================>]   3,58K  --.-KB/s    in 0s      

2022-04-05 14:13:51 (344 MB/s) - ‘notFound’ saved [3665/3665]

Expected behavior

Status 404 or any other status, which set as return value should be returned instead.

Minimal reproducible example

  • Download sample project from start.vaadin.com
  • Add RouteNotFoundView given at bug description.
  • Run project
  • visit any non-existent route

Versions

  • Vaadin / Flow version: 23.0.3
  • Java version: 17.0.3
  • OS version: Linux Manjaro, kernel 5.16.14-1-MANJARO
  • Browser version (if applicable): Firefox 98.0.2
  • Application Server (if applicable): the one goes with Spring Boot
  • IDE (if applicable): Intelij IDEA

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:4
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
paulroemercommented, Jul 5, 2022

I can confirm that with 23.1.3 eagerServerLoad works as expected and the application behaves as it should again. As Leif already mentioned above, this only works for applications that only use server-side routes.

For SpringBoot apps just add

vaadin.eagerServerLoad=true
1reaction
platoshacommented, Jun 27, 2022

Apart from the bug addressed in #14036, the documentation is currently misleading here to not mention a different behavior with and without eagerServerLoad enabled. See https://github.com/vaadin/docs/issues/1521

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spring Boot binding and validation error handling in REST ...
This is the code what i have used in one of my project for validating REST api in spring boot,this is not same...
Read more >
Handling Errors the PowerShell Way - Scripting Blog
The -ErrorAction common parameter allows you to specify which action to take if a command fails. The available options are: Stop, Continue, ...
Read more >
AbstractControl - Angular
The first type parameter TValue represents the value type of the control ... An object containing any errors generated by failing validation, ...
Read more >
Exceptions and debugging - Advanced R. - Hadley Wickham
Debugging, condition handling, and defensive programming. What happens when something goes ... What function do you use to ignore errors in block of...
Read more >
Validation and Error Handling in AngularJS Applications
Everything you should know about validation and errors in AngularJS apps: good ... AngularJS) which accepts custom verification function as input parameter.
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