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
22 lines
1.0 KiB
Bash
22 lines
1.0 KiB
Bash
#!/usr/bin/env bash
|
|
# What Accept header gets which error body. Profile: advice. -> docs/output/content-negotiation.txt
|
|
set -uo pipefail
|
|
source "$(dirname "$0")/env.sh"
|
|
"$MODULE_DIR/scripts/run.sh" advice || exit 1
|
|
{
|
|
echo "# Accept header vs error body (profile: advice, jackson-dataformat-xml on the classpath)"
|
|
echo
|
|
echo "## A successful response, for comparison"
|
|
echo '$ curl -H "Accept: application/xml" /orders/1'
|
|
curl -s -i -H 'Accept: application/xml' "$BASE/orders/1" | grep -iE '^HTTP|^content-type' | tr -d '\r'
|
|
curl -s -H 'Accept: application/xml' "$BASE/orders/1"; echo; echo
|
|
for a in 'application/json' 'application/xml' 'application/problem+xml' 'text/html' 'image/png' '*/*'; do
|
|
echo "## Accept: $a"
|
|
echo "\$ curl -H \"Accept: $a\" /orders/999"
|
|
curl -s -i -H "Accept: $a" "$BASE/orders/999" | grep -iE '^HTTP|^content-type' | tr -d '\r'
|
|
curl -s -H "Accept: $a" "$BASE/orders/999"; echo; echo
|
|
done
|
|
} > "$OUT/content-negotiation.txt"
|
|
"$MODULE_DIR/scripts/stop.sh"
|
|
cat "$OUT/content-negotiation.txt"
|