Add problem-details: global exception handling with RFC 9457
Companion code for "Global Exception Handling with ProblemDetail (RFC 9457) in Spring Boot 4". Thirteen failures under five handling setups (Boot defaults, the Boot flag, a ResponseEntityExceptionHandler advice, advice plus an ErrorController, a catch-all ordered first), validation errors, i18n, content negotiation, Security's 401/403, silent 500s and decoding on the client. 16 tests pin the behaviour. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01C3TETMrqVUWeFkNtz3Jbo3
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
# Accept header vs error body (profile: advice, jackson-dataformat-xml on the classpath)
|
||||
|
||||
## A successful response, for comparison
|
||||
$ curl -H "Accept: application/xml" /orders/1
|
||||
HTTP/1.1 200
|
||||
Content-Type: application/xml;charset=UTF-8
|
||||
<Order><id>1</id><sku>SKU-1</sku><quantity>2</quantity></Order>
|
||||
|
||||
## Accept: application/json
|
||||
$ curl -H "Accept: application/json" /orders/999
|
||||
HTTP/1.1 404
|
||||
Content-Type: application/problem+json
|
||||
{"detail":"Order 999 does not exist","instance":"/orders/999","status":404,"title":"Order not found","type":"https://ankurm.com/problems/order-not-found","orderId":999}
|
||||
|
||||
## Accept: application/xml
|
||||
$ curl -H "Accept: application/xml" /orders/999
|
||||
HTTP/1.1 404
|
||||
Content-Type: application/problem+json
|
||||
{"detail":"Order 999 does not exist","instance":"/orders/999","status":404,"title":"Order not found","type":"https://ankurm.com/problems/order-not-found","orderId":999}
|
||||
|
||||
## Accept: application/problem+xml
|
||||
$ curl -H "Accept: application/problem+xml" /orders/999
|
||||
HTTP/1.1 404
|
||||
Content-Type: application/problem+xml
|
||||
<problem xmlns="urn:ietf:rfc:7807"><detail>Order 999 does not exist</detail><instance>/orders/999</instance><status>404</status><title>Order not found</title><type>https://ankurm.com/problems/order-not-found</type><orderId>999</orderId></problem>
|
||||
|
||||
## Accept: text/html
|
||||
$ curl -H "Accept: text/html" /orders/999
|
||||
HTTP/1.1 404
|
||||
Content-Type: application/problem+json
|
||||
{"detail":"Order 999 does not exist","instance":"/orders/999","status":404,"title":"Order not found","type":"https://ankurm.com/problems/order-not-found","orderId":999}
|
||||
|
||||
## Accept: image/png
|
||||
$ curl -H "Accept: image/png" /orders/999
|
||||
HTTP/1.1 404
|
||||
Content-Type: application/problem+json
|
||||
{"detail":"Order 999 does not exist","instance":"/orders/999","status":404,"title":"Order not found","type":"https://ankurm.com/problems/order-not-found","orderId":999}
|
||||
|
||||
## Accept: */*
|
||||
$ curl -H "Accept: */*" /orders/999
|
||||
HTTP/1.1 404
|
||||
Content-Type: application/problem+json
|
||||
{"detail":"Order 999 does not exist","instance":"/orders/999","status":404,"title":"Order not found","type":"https://ankurm.com/problems/order-not-found","orderId":999}
|
||||
|
||||
Reference in New Issue
Block a user