Production error handling for Express APIs — error middleware, async wrappers,
89
86%
Does it follow best practices?
Impact
97%
2.02xAverage score across 4 eval scenarios
Passed
No known issues
{
"context": "Tests whether the agent proactively adds production error handling when building a multi-resource e-commerce API. The task does not mention error handling -- criteria check for global error middleware, async safety, structured responses, and proper status codes for various failure modes (validation, not found, insufficient stock).",
"type": "weighted_checklist",
"checklist": [
{
"name": "Global error middleware",
"description": "A centralized error-handling middleware with 4 arguments (err, req, res, next) is defined and registered after all routes",
"max_score": 14
},
{
"name": "Async error safety",
"description": "All async route handlers are protected via asyncHandler wrapper, try/catch with next(err), or express-async-errors. No bare async handlers.",
"max_score": 14
},
{
"name": "Structured error responses",
"description": "All error responses follow a consistent shape (e.g. { error: { code, message } }). No mixed formats across different routes.",
"max_score": 12
},
{
"name": "No internal error leaks",
"description": "Unexpected errors return a generic message -- no stack traces, raw error strings, or internal paths exposed to the client",
"max_score": 10
},
{
"name": "Validation with details",
"description": "Validation errors for the complex POST /api/orders endpoint include information about which fields or items failed and why",
"max_score": 10
},
{
"name": "Not-found handling",
"description": "Requests for non-existent products or orders return 404, not 500 or 200 with an error message",
"max_score": 8
},
{
"name": "Business rule error handling",
"description": "Insufficient stock or similar business rule violations return an appropriate 4xx status (e.g. 400, 409, or 422), not 500",
"max_score": 8
},
{
"name": "404 catch-all",
"description": "Unmatched routes get a JSON 404 response instead of Express's default HTML error page",
"max_score": 7
},
{
"name": "Graceful shutdown",
"description": "Process signal handlers (SIGTERM/SIGINT) are registered with server.close()",
"max_score": 7
},
{
"name": "Appropriate status codes",
"description": "Different error types return different HTTP status codes: 400 for validation, 404 for not found, appropriate 4xx for business rules, 500 for unexpected -- not all errors mapped to the same code",
"max_score": 10
}
]
}