Questions tagged [controller-advice]

113 questions
0
votes
2 answers

@ControllerAdvice never gets triggered in Spring Boot

I am trying to create my own custom response for all types of RestClientResponseException in my Spring Boot Application Custom exception thrown from Controller class : throw new HealthCheckRestException(ex.getResponseBodyAsString()); My…
sayak
  • 3
  • 2
0
votes
1 answer

spring mvc: applying @ModelAttribute on non-@Controller endpoints

I've read this suggestion on using @ModelAttribute for injecting parameters to the model globally. Is my understading correct, that such an approach will not cover views rendered by, e.g. , or a form-login custom login page? If…
0
votes
0 answers

Custom Exception handling giving error Servlet.service() for servlet [dispatcherServlet]

I have created a custom exception handling. I thought I have made it worked because it shows the error page on localhost and it's giving the correct info when I used the postman. However, on my terminal it's giving me this error ->…
Angge
  • 25
  • 8
0
votes
1 answer

Optimize Spring RestControllerAdvice with multiple exceptions

I have around 20 to 30 different types of different Exceptions all extending Exception class in Java. one example is: public class NoHandlerFoundException extends Exception { private static final long serialVersionUID =…
0
votes
0 answers

How to get the request object for MaxUploadSizeExceededException

I'm developing a RESTful api using spring boot 2 and trying to upload a file with limit set in the yml file as servlet.multipart.max-file-size=2MB. As per my requirement any file size uploaded above 2MB need to inserted into the database with the…
Rabikatha
  • 249
  • 5
  • 9
0
votes
1 answer

Unit Test for a Controller Advice without calling the controller

I'm trying to write a unit test for a controllerAdvice, all the example I saw in the net are for an integration test, that's mean they are calling their main Rest controller and I dont want to do in that way. here is the test i'm trying to write…
Mohamed Taboubi
  • 6,663
  • 11
  • 55
  • 87
-1
votes
2 answers

My authentication exceptions are not handled

I am currently trying to create a fullstack app, with Angular 14 and spring boot, i am stack with authentication. my problem is that i use my own form to get the password and the username from the user, then trying to authenticate in the backend, i…
-1
votes
1 answer

ControllerAdvice cannot catch custom exception in Spring Boot

I use a global exception handler built by @ControllerAdvice as shown below and I catch custom exception e.g. NoSuchElementFoundException without any problem. If there is any uncaught error, then handleAllUncaughtException catches them. On the other…
user19601508
1 2 3 4 5 6 7
8