Class RestControllerAdvice
java.lang.Object
org.springframework.cloud.dataflow.server.controller.RestControllerAdvice
Apply common behavior (exception handling etc.,) to all the REST controllers.
- Author:
- Eric Bottard, Gunnar Hillert, Ilayaperumal Gopinathan, Christian Tzolov
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.hateoas.mediatype.vnderrors.VndErrors
Client did not formulate a correct request.org.springframework.hateoas.mediatype.vnderrors.VndErrors
Log the exception message at warn level and stack trace as trace level.org.springframework.hateoas.mediatype.vnderrors.VndErrors
onConstraintViolationException
(jakarta.validation.ConstraintViolationException e) The exception handler is trigger if a JSR303ConstraintViolationException
is being raised.org.springframework.hateoas.mediatype.vnderrors.VndErrors
Handles the general error case.org.springframework.hateoas.mediatype.vnderrors.VndErrors
Log the exception message at warn level and stack trace as trace level.org.springframework.hateoas.mediatype.vnderrors.VndErrors
Log the exception message at warn level and stack trace as trace level.
-
Constructor Details
-
RestControllerAdvice
public RestControllerAdvice()
-
-
Method Details
-
onException
@ExceptionHandler(java.lang.Exception.class) @ResponseStatus(INTERNAL_SERVER_ERROR) @ResponseBody public org.springframework.hateoas.mediatype.vnderrors.VndErrors onException(Exception e) Handles the general error case. Log track trace at error level- Parameters:
e
- the exception not handled by other exception handler methods- Returns:
- the error response in JSON format with media type application/vnd.error+json
-
onConflictException
@ExceptionHandler({AppAlreadyRegisteredException.class,DuplicateStreamDefinitionException.class,DuplicateTaskException.class,StreamAlreadyDeployedException.class,StreamAlreadyDeployingException.class,UnregisterAppException.class,InvalidCTRLaunchRequestException.class}) @ResponseStatus(CONFLICT) @ResponseBody public org.springframework.hateoas.mediatype.vnderrors.VndErrors onConflictException(Exception e) Log the exception message at warn level and stack trace as trace level. Return response status HttpStatus.CONFLICT- Parameters:
e
- one of the exceptions,AppAlreadyRegisteredException
,DuplicateStreamDefinitionException
,DuplicateTaskException
,StreamAlreadyDeployedException
,StreamAlreadyDeployingException
,StreamAlreadyDeployingException
, orApiNotSupportedException
- Returns:
- the error response in JSON format with media type application/vnd.error+json
-
onUnprocessableEntityException
@ExceptionHandler({JobNotRestartableException.class,org.springframework.batch.core.launch.JobExecutionNotRunningException.class}) @ResponseStatus(UNPROCESSABLE_ENTITY) @ResponseBody public org.springframework.hateoas.mediatype.vnderrors.VndErrors onUnprocessableEntityException(Exception e) Log the exception message at warn level and stack trace as trace level. Return response status HttpStatus.UNPROCESSABLE_ENTITY- Parameters:
e
- one of the exceptions,JobNotRestartableException
orJobExecutionNotRunningException
- Returns:
- the error response in JSON format with media type application/vnd.error+json
-
onNotFoundException
@ExceptionHandler({NoSuchAuditRecordException.class,NoSuchStreamDefinitionException.class,NoSuchAppRegistrationException.class,NoSuchTaskDefinitionException.class,NoSuchTaskExecutionException.class,org.springframework.batch.core.launch.NoSuchJobExecutionException.class,org.springframework.batch.core.launch.NoSuchJobInstanceException.class,org.springframework.batch.core.launch.NoSuchJobException.class,NoSuchStepExecutionException.class,NoSuchTaskBatchException.class,NoSuchAppException.class,NoSuchAppInstanceException.class,NoSuchScheduleException.class}) @ResponseStatus(NOT_FOUND) @ResponseBody public org.springframework.hateoas.mediatype.vnderrors.VndErrors onNotFoundException(Exception e) Log the exception message at warn level and stack trace as trace level. Return response status HttpStatus.NOT_FOUND- Parameters:
e
- one of the exceptions,NoSuchAuditRecordException
,NoSuchStreamDefinitionException
,NoSuchAppRegistrationException
,NoSuchTaskDefinitionException
,NoSuchTaskExecutionException
,NoSuchJobExecutionException
,NoSuchJobInstanceException
,NoSuchJobException
,NoSuchStepExecutionException
,NoSuchAppException
,NoSuchAppInstanceException
, or- Returns:
- the error response in JSON format with media type application/vnd.error+json
-
onClientGenericBadRequest
@ExceptionHandler({ApiNotSupportedException.class,org.springframework.web.bind.MissingServletRequestParameterException.class,org.springframework.http.converter.HttpMessageNotReadableException.class,org.springframework.web.bind.UnsatisfiedServletRequestParameterException.class,org.springframework.web.method.annotation.MethodArgumentTypeMismatchException.class,InvalidDateRangeException.class,CannotDeleteNonParentTaskExecutionException.class,InvalidStreamDefinitionException.class,org.springframework.cloud.deployer.spi.scheduler.CreateScheduleException.class,OffsetOutOfBoundsException.class,TaskExecutionMissingExternalIdException.class,TaskQueryParamException.class,InvalidApplicationNameException.class}) @ResponseStatus(BAD_REQUEST) @ResponseBody public org.springframework.hateoas.mediatype.vnderrors.VndErrors onClientGenericBadRequest(Exception e) Client did not formulate a correct request. Log the exception message at warn level and stack trace as trace level. Return response status HttpStatus.BAD_REQUEST (400).- Parameters:
e
- one of the exceptions,MissingServletRequestParameterException
,UnsatisfiedServletRequestParameterException
,MethodArgumentTypeMismatchException
,InvalidStreamDefinitionException
orInvalidApplicationNameException
- Returns:
- the error response in JSON format with media type application/vnd.error+json
-
onConstraintViolationException
@ExceptionHandler(jakarta.validation.ConstraintViolationException.class) @ResponseStatus(BAD_REQUEST) @ResponseBody public org.springframework.hateoas.mediatype.vnderrors.VndErrors onConstraintViolationException(jakarta.validation.ConstraintViolationException e) The exception handler is trigger if a JSR303ConstraintViolationException
is being raised.Log the exception message at warn level and stack trace as trace level. Return response status HttpStatus.BAD_REQUEST (400).
- Parameters:
e
- the exceptions,ConstraintViolationException
- Returns:
- the error response in JSON format with media type application/vnd.error+json
-