Answer the question
In order to leave comments, you need to log in
Why does the request hang when exceptions are thrown?
A very interesting situation is obtained.
When I use ExceptionHandler the request hangs waiting for a response.
ExceptionHandler:
@RestControllerAdvice
public class ExceptionAPIHandler {
@ExceptionHandler(value = SourceException.class)
public ResponseEntity<DataException> handleException(SourceException exception) {
final HttpStatus code = exception.getCode();
final DataException dataException = new DataException(exception.getMessage(), code);
return ResponseEntity.status(code).body(dataException);
}
}
@RestControllerAdvice
public class ExceptionAPIHandler {
@ResponseBody
@ExceptionHandler(value = SourceException.class)
public ResponseEntity<?> handleException(SourceException exception) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new DataException(exception.getMessage(), exception.getCode()));
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question