Files
spring-boot-demo/problem-details/docs/output/content-negotiation.txt
T
asmhatreandClaude Opus 5 926250e1a9 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
2026-09-11 17:12:22 +00:00

45 lines
2.1 KiB
Plaintext

# 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}