Package com.homannsoftware.tasks.task
Class ApiErrors
java.lang.Object
org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
com.homannsoftware.tasks.task.ApiErrors
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.context.MessageSourceAware
@RestControllerAdvice
public class ApiErrors
extends org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
Maps application failures to RFC 9457 Problem Details.
Inherited handlers cover Spring MVC request and validation failures.
-
Field Summary
Fields inherited from class org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
logger, PAGE_NOT_FOUND_LOG_CATEGORY, pageNotFoundLogger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ProblemDetailconflict(org.springframework.dao.OptimisticLockingFailureException error) Translates stale persistence writes into an HTTP 409 conflict.org.springframework.http.ProblemDetailmissing(TaskNotFound error) Translates a missing task into a public HTTP 404 problem.Methods inherited from class org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
createProblemDetail, createResponseEntity, getMessageSource, handleAsyncRequestNotUsableException, handleAsyncRequestTimeoutException, handleConversionNotSupported, handleErrorResponseException, handleException, handleExceptionInternal, handleHandlerMethodValidationException, handleHttpMediaTypeNotAcceptable, handleHttpMediaTypeNotSupported, handleHttpMessageNotReadable, handleHttpMessageNotWritable, handleHttpRequestMethodNotSupported, handleMaxUploadSizeExceededException, handleMethodArgumentNotValid, handleMethodValidationException, handleMissingPathVariable, handleMissingServletRequestParameter, handleMissingServletRequestPart, handleNoHandlerFoundException, handleNoResourceFoundException, handleServletRequestBindingException, handleTypeMismatch, setMessageSource
-
Constructor Details
-
ApiErrors
public ApiErrors()Creates the shared HTTP exception handler managed by Spring.
-
-
Method Details
-
missing
@ExceptionHandler(TaskNotFound.class) public org.springframework.http.ProblemDetail missing(TaskNotFound error) Translates a missing task into a public HTTP 404 problem.- Parameters:
error- application failure identifying the missing task- Returns:
- problem detail with NOT_FOUND status and the missing identity
-
conflict
@ExceptionHandler(org.springframework.dao.OptimisticLockingFailureException.class) public org.springframework.http.ProblemDetail conflict(org.springframework.dao.OptimisticLockingFailureException error) Translates stale persistence writes into an HTTP 409 conflict.- Parameters:
error- persistence failure, deliberately excluded from public detail- Returns:
- problem detail advising the client to read current state
-