@Test public void test() { final ResponseEntity<RestError> entity = restExceptionHandler.handleResponseEntityException( new RestResourceNotFoundException( "This is a test." ), webRequest ); Assert.assertEquals( HttpStatus.NOT_FOUND, entity.getStatusCode() ); Assert.assertNotNull( entity.getBody() ); Assert.assertEquals( "This is a test.", entity.getBody().getMessage() ); }
@ExceptionHandler( value = { RestResponseEntityException.class } ) @ResponseBody public ResponseEntity<RestError> handleResponseEntityException( RestResponseEntityException e, WebRequest request ) { return new ResponseEntity<>( new RestError( e.getMessage() ), e.getHttpStatus() ); }
RestExceptionHandler extends ResponseEntityExceptionHandler { @ExceptionHandler( value = { RestResponseEntityException.class } ) @ResponseBody public ResponseEntity<RestError> handleResponseEntityException( RestResponseEntityException e, WebRequest request ) { return new ResponseEntity<>( new RestError( e.getMessage() ), e.getHttpStatus() ); } }
RestExceptionHandler extends ResponseEntityExceptionHandler { @ExceptionHandler( value = { RestResponseEntityException.class } ) @ResponseBody public ResponseEntity<RestError> handleResponseEntityException( RestResponseEntityException e, WebRequest request ) { return new ResponseEntity<>( new RestError( e.getMessage() ), e.getHttpStatus() ); }  }
RestExceptionHandler extends ResponseEntityExceptionHandler { @ExceptionHandler( value = { RestResponseEntityException.class } ) @ResponseBody public ResponseEntity<RestError> handleResponseEntityException( RestResponseEntityException e, WebRequest request ) { return new ResponseEntity<>( new RestError( e.getMessage() ), e.getHttpStatus() ); }  @ExceptionHandler( value = { RestResponseEntityException.class } ) @ResponseBody ResponseEntity<RestError> handleResponseEntityException( RestResponseEntityException e, WebRequest request ); }
RestExceptionHandler extends ResponseEntityExceptionHandler { @ExceptionHandler( value = { RestResponseEntityException.class } ) @ResponseBody public ResponseEntity<RestError> handleResponseEntityException( RestResponseEntityException e, WebRequest request ) { return new ResponseEntity<>( new RestError( e.getMessage() ), e.getHttpStatus() ); }  @ExceptionHandler( value = { RestResponseEntityException.class } ) @ResponseBody ResponseEntity<RestError> handleResponseEntityException( RestResponseEntityException e, WebRequest request );  }