rrezartprebreza/spring-boot-skills / skills/spring-boot-4/problem-details-rfc9457
problem-details-rfc9457
VerifiedUse when implementing exception mapping or RFC 9457 error responses in Spring Boot 4. Preserve an existing legacy error contract unless migration is requested.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 4.0 KB |
| agents/openai.yaml | config | 211 B |
| examples/bad-exception-handler.java | other | 1.6 KB |
| examples/good-exception-handler.java | other | 3.0 KB |
| templates/BusinessRuleViolationException.java | other | 358 B |
| templates/DomainException.java | other | 622 B |
| templates/InsufficientInventoryException.java | other | 513 B |
| templates/OrderNotFoundException.java | other | 366 B |
| templates/ProblemDetailExceptionHandler.java | other | 3.8 KB |
examples/bad-exception-handler.java
View on GitHub// BAD — returns Map, exposes internals, wrong status codes
@RestControllerAdvice
public class GlobalExceptionHandler { // no framework error handling shown
@ExceptionHandler(OrderNotFoundException.class)
public Map<String, Object> handleNotFound(OrderNotFoundException ex) {
return Map.of( // returns Map, not ProblemDetail
"error", ex.getMessage(),
"status", 404
); // body says 404 but HTTP status remains 200
}
@ExceptionHandler(BusinessRuleViolationException.class)
public ResponseEntity<Map<String, String>> handleBusinessRule(BusinessRuleViolationException ex) {
return ResponseEntity.ok( // returns 200 with error body!
Map.of("error", ex.getMessage())); // should be 422 Unprocessable Entity
}
@ExceptionHandler(Exception.class)
public ResponseEntity<Map<String, Object>> handleGeneric(Exception ex) {
return ResponseEntity.status(500).body(Map.of(
"error", ex.getMessage(), // exposes raw exception message (security risk)
"stackTrace", Arrays.toString(ex.getStackTrace()) // NEVER expose stack traces
));
}
@ExceptionHandler(MethodArgumentNotValidException.class)
public ResponseEntity<String> handleValidation(MethodArgumentNotValidException ex) {
return ResponseEntity.badRequest()
.body("Validation failed: " + ex.getMessage()); // raw string, no structure
}
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |