Error handling for Spring Boot APIs — @ControllerAdvice, structured error
84
75%
Does it follow best practices?
Impact
99%
1.76xAverage score across 5 eval scenarios
Passed
No known issues
{
"context": "Tests whether the agent proactively adds production-grade error handling when building a Spring Boot event booking API with complex business rules and state transitions. The task has many error-prone scenarios (capacity checks, status transitions, date validation) but never mentions error handling patterns.",
"type": "weighted_checklist",
"checklist": [
{
"name": "Global exception handler with @RestControllerAdvice",
"description": "A centralized exception handler class annotated with @RestControllerAdvice or @ControllerAdvice is defined, with @ExceptionHandler methods for multiple exception types including validation, not-found, business rule, and generic exceptions",
"max_score": 15
},
{
"name": "Custom exception hierarchy",
"description": "Custom exception classes with HTTP status mapping are used for different error scenarios (not-found events/bookings, insufficient capacity, invalid status transitions, duplicate bookings) instead of generic exceptions",
"max_score": 12
},
{
"name": "Consistent structured error response format",
"description": "All error responses follow the same shape with a code and message field. Not a mix of different response structures from different endpoints",
"max_score": 12
},
{
"name": "Validation error handler with field details",
"description": "MethodArgumentNotValidException is handled in the global handler, returning structured field-level errors for invalid request body fields",
"max_score": 12
},
{
"name": "No stack trace leaks",
"description": "Catch-all Exception handler returns a generic safe message. No stack traces, internal paths, or raw library error messages in responses",
"max_score": 12
},
{
"name": "Bean validation with @Valid",
"description": "@Valid on @RequestBody parameters and Jakarta Validation annotations on DTOs/records for declarative input validation (e.g., @NotBlank, @Positive, @Min, @Max, @Future for dates)",
"max_score": 10
},
{
"name": "Appropriate HTTP status codes",
"description": "Semantically correct status codes: 400 for validation errors, 404 for not-found events/bookings, 409 for duplicate booking or capacity conflicts, 422 for invalid status transitions or past dates, 500 for unexpected",
"max_score": 10
},
{
"name": "Business rule violations as typed errors",
"description": "Business rule violations (insufficient capacity, invalid status transition, past event date, duplicate email booking) throw typed exceptions that the global handler maps to appropriate HTTP responses -- not handled with inline ResponseEntity returns",
"max_score": 7
},
{
"name": "CRUD endpoints functional",
"description": "Core event and booking endpoints are implemented with correct success status codes and business logic",
"max_score": 10
}
]
}