Class GlobalExceptionHandler

java.lang.Object
dev.dokimos.server.controller.GlobalExceptionHandler

@RestControllerAdvice public class GlobalExceptionHandler extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.springframework.http.ResponseEntity<Map<String,Object>>
     
    org.springframework.http.ResponseEntity<Map<String,Object>>
    handleDataIntegrity(org.springframework.dao.DataIntegrityViolationException ex)
    Maps a database constraint violation to a 409 rather than a 500.
    org.springframework.http.ResponseEntity<Map<String,Object>>
     
    org.springframework.http.ResponseEntity<Map<String,Object>>
    handleMissingParam(org.springframework.web.bind.MissingServletRequestParameterException ex)
    Maps a missing required query parameter (for example baselineRunId on the diff endpoint) to a 400 rather than letting it fall through to the generic 500 handler.
    org.springframework.http.ResponseEntity<Map<String,Object>>
     
    org.springframework.http.ResponseEntity<Map<String,Object>>
    handleResponseStatus(org.springframework.web.server.ResponseStatusException ex)
    Honors the status carried by a ResponseStatusException (for example a 400 raised by a controller for an unrecognized query-parameter value) instead of letting the generic handler collapse it to a 500.
    org.springframework.http.ResponseEntity<Map<String,Object>>
    handleUnreadableBody(org.springframework.http.converter.HttpMessageNotReadableException ex)
    Maps an unparseable or type-mismatched request body (for example a malformed UUID) to a 400 rather than letting it fall through to the generic 500 handler.
    org.springframework.http.ResponseEntity<Map<String,Object>>
    handleValidation(org.springframework.web.bind.MethodArgumentNotValidException ex)
    Maps bean-validation failures on @RequestBody payloads to a 400, surfacing the first field error message so the caller sees which constraint failed instead of an opaque 500.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • GlobalExceptionHandler

      public GlobalExceptionHandler()
  • Method Details

    • handleNotFound

      @ExceptionHandler(java.lang.IllegalArgumentException.class) public org.springframework.http.ResponseEntity<Map<String,Object>> handleNotFound(IllegalArgumentException ex)
    • handleConflict

      @ExceptionHandler(java.lang.IllegalStateException.class) public org.springframework.http.ResponseEntity<Map<String,Object>> handleConflict(IllegalStateException ex)
    • handleValidation

      @ExceptionHandler(org.springframework.web.bind.MethodArgumentNotValidException.class) public org.springframework.http.ResponseEntity<Map<String,Object>> handleValidation(org.springframework.web.bind.MethodArgumentNotValidException ex)
      Maps bean-validation failures on @RequestBody payloads to a 400, surfacing the first field error message so the caller sees which constraint failed instead of an opaque 500.
    • handleMissingParam

      @ExceptionHandler(org.springframework.web.bind.MissingServletRequestParameterException.class) public org.springframework.http.ResponseEntity<Map<String,Object>> handleMissingParam(org.springframework.web.bind.MissingServletRequestParameterException ex)
      Maps a missing required query parameter (for example baselineRunId on the diff endpoint) to a 400 rather than letting it fall through to the generic 500 handler.
    • handleUnreadableBody

      @ExceptionHandler(org.springframework.http.converter.HttpMessageNotReadableException.class) public org.springframework.http.ResponseEntity<Map<String,Object>> handleUnreadableBody(org.springframework.http.converter.HttpMessageNotReadableException ex)
      Maps an unparseable or type-mismatched request body (for example a malformed UUID) to a 400 rather than letting it fall through to the generic 500 handler.
    • handleResponseStatus

      @ExceptionHandler(org.springframework.web.server.ResponseStatusException.class) public org.springframework.http.ResponseEntity<Map<String,Object>> handleResponseStatus(org.springframework.web.server.ResponseStatusException ex)
      Honors the status carried by a ResponseStatusException (for example a 400 raised by a controller for an unrecognized query-parameter value) instead of letting the generic handler collapse it to a 500.
    • handleDataIntegrity

      @ExceptionHandler(org.springframework.dao.DataIntegrityViolationException.class) public org.springframework.http.ResponseEntity<Map<String,Object>> handleDataIntegrity(org.springframework.dao.DataIntegrityViolationException ex)
      Maps a database constraint violation to a 409 rather than a 500. This covers the rare race where two concurrent writes both try to create a row guarded by a unique constraint (for example two simultaneous first-time annotations on the same item result); the loser gets a clean conflict it can retry instead of an opaque server error.
    • handleGeneral

      @ExceptionHandler(java.lang.Exception.class) public org.springframework.http.ResponseEntity<Map<String,Object>> handleGeneral(Exception ex)