Questions tagged [exceptionhandler]

127 questions
25
votes
1 answer

$location from $exceptionHandler - dependency conflict

I'm trying to implement a very standard task: when an exception occurs, redirect to my /error page. In a simplified form the code looks like this: app.factory('$exceptionHandler', ['$location', function($location) { return function(exception,…
vitaly-t
  • 20,421
  • 5
  • 85
  • 117
17
votes
3 answers

Getting Ambiguous @ExceptionHandler method mapped for MethodArgumentNotValidException while startup of spring boot application

I have written custom exception handler class for one of my spring controllers to validate if email attribute from request param is in the proper format. So created a new class which extends ResponseEntityExceptionHandler class and wrote a method…
15
votes
3 answers

Reading httprequest content from spring exception handler

I Am using Spring's @ExceptionHandler annotation to catch exceptions in my controllers. Some requests hold POST data as plain XML string written to the request body, I want to read that data in order to log the exception. The problem is that when i…
Noam Nevo
  • 2,763
  • 9
  • 30
  • 48
11
votes
1 answer

BindException thrown instead of MethodArgumentNotValidException in REST application

I have a simple Spring Rest Controller with some validation. My understanding is that validation failures would throw a MethodArgumentNotValidException. However, my code throws a BindException instead. In debug messages, I also see the app returning…
Jigish
  • 1,614
  • 15
  • 19
10
votes
1 answer

How does spring manage ExceptionHandler priority?

Giving this controller @GetMapping("/test") @ResponseBody public String test() { if (!false) { throw new IllegalArgumentException(); } return "blank"; } @ResponseStatus(value =…
Olivier Boissé
  • 9,568
  • 4
  • 27
  • 43
10
votes
5 answers

spring mvc @ExceptionHandler method get same view

My problem is that I want to create an @ExceptionHandler method that will capture all un-handled exceptions. Once captured I would like to redirect to the current page instead of specifying a separate page just to display error. Basically how do I…
vincent
  • 233
  • 1
  • 5
  • 16
8
votes
3 answers

How could we use @ExceptionHandler with spring web flux?

In spring web we could use annotation @ExceptionHandler for handling server and client errors for controllers. I've tried to use this annotation with web-flux controller and it still worked for me, but after some investigation I've found out…
Evgen
  • 998
  • 2
  • 9
  • 21
7
votes
3 answers

@ControllerAdvice and @ExceptionHandler not getting triggered for my RestController

In order to have unified exception handling throughout the application I am using Error Handling for REST with Spring solution#3 which uses @ControllerAdvice along with @ExceptionHandler. Spring version: 4.3.22.RELEASE Spring Boot version:…
7
votes
1 answer

Throwing an exception from @ExceptionHandler to get caught by another handler

I have a @ControllerAdvice class to handle exceptions from my SpringMVC controllers. I would like to catch an exception of a known type (RuntimeException) in an @ExceptionHandler method then throw the e.getCause() exception and have this exception…
agentgonzo
  • 2,853
  • 3
  • 19
  • 25
6
votes
1 answer

"View Details " missing form Exception handler VS 2017

This could easily be the same as: 'View Details' missing from exception assistant But I am seeing it in VS 2017. Flipping "Use Managed Compatibility Mode" doesn't seem to make a difference. This is what the window looks like: With "View Details"…
chrispepper1989
  • 1,742
  • 1
  • 19
  • 41
6
votes
2 answers

Web API global error handling add custom header in response

I was wondering if it was possible to set some custom header values whenever an internal server error has occurred? I am currently doing: public class FooExceptionHandler : ExceptionHandler { public override void Handle(ExceptionHandlerContext…
Dr Schizo
  • 3,245
  • 3
  • 28
  • 65
6
votes
1 answer

Why FullAjaxExceptionHandler does not simply perform an ExternalContext#redirect()?

In OmniFaces, the FullAjaxExceptionHandler, after having found the right error page to use, calls the JSF runtime to build the view and render it instead of the page that includes the AJAX call. Why this? IMHO it would be simpler to just perform a…
titou10
  • 2,149
  • 1
  • 14
  • 33
5
votes
0 answers

Spring @ControllerAdvice ExceptionHandler based on content type

We have a need to support both html and json responses in all our end points. The html will be used by our own front-end application and json will be used by third-party API integrations. We have used ContentNegotiatingViewResolver to use JstlView…
Anupama
  • 167
  • 1
  • 9
5
votes
3 answers

Return HTTP status code dynamically as per the request using @ExceptionHandler

I want to return HTTPStatus code dynamically like 400, 400, 404 etc as per the response object error. I was referred to this question - Programmatically change http response status using spring 3 restful but it did not help. I have this Controller…
user2340345
  • 677
  • 1
  • 11
  • 29
5
votes
2 answers

why linux set the data-segment to __USER_DS at the prologue of exception handler

I'm trying to read Linux source code(2.6.11) In the exception handler, at entry.s, error_code: movl $(__USER_DS), %ecx movl %ecx, %ds movl %ecx, %es I don't know why loading user data segment here. Since it is supposed to be entering the exception…
Holmes
  • 63
  • 4
1
2 3
8 9