Package dev.dokimos.server.controller
Class GlobalExceptionHandler
java.lang.Object
dev.dokimos.server.controller.GlobalExceptionHandler
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionhandleDataIntegrity(org.springframework.dao.DataIntegrityViolationException ex) Maps a database constraint violation to a 409 rather than a 500.handleMissingParam(org.springframework.web.bind.MissingServletRequestParameterException ex) Maps a missing required query parameter (for examplebaselineRunIdon the diff endpoint) to a 400 rather than letting it fall through to the generic 500 handler.handleResponseStatus(org.springframework.web.server.ResponseStatusException ex) Honors the status carried by aResponseStatusException(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.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.handleValidation(org.springframework.web.bind.MethodArgumentNotValidException ex) Maps bean-validation failures on@RequestBodypayloads to a 400, surfacing the first field error message so the caller sees which constraint failed instead of an opaque 500.
-
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@RequestBodypayloads 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 examplebaselineRunIdon 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 aResponseStatusException(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)
-