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,20 @@
|
||||
#!/usr/bin/env bash
|
||||
# title/detail resolved from messages*.properties for an ErrorResponseException. -> docs/output/i18n.txt
|
||||
set -uo pipefail
|
||||
source "$(dirname "$0")/env.sh"
|
||||
"$MODULE_DIR/scripts/run.sh" advice || exit 1
|
||||
BODY='{"sku":"SKU-2","quantity":3,"customerEmail":"[email protected]"}'
|
||||
{
|
||||
echo "# OutOfStockException - its own ProblemDetail vs messages.properties vs messages_de.properties"
|
||||
echo
|
||||
echo "## Exception's own text (what the constructor set):"
|
||||
echo " title=\"Insufficient stock\" detail=\"Requested 3 of SKU-2 but only 0 available\""
|
||||
echo
|
||||
for lang in '' 'de'; do
|
||||
echo "## Accept-Language: ${lang:-<none>}"
|
||||
echo "\$ curl -X POST /orders -d '$BODY'${lang:+ -H 'Accept-Language: $lang'}"
|
||||
curl -s -X POST "$BASE/orders" -H 'Content-Type: application/json' ${lang:+-H "Accept-Language: $lang"} --data "$BODY"; echo; echo
|
||||
done
|
||||
} > "$OUT/i18n.txt"
|
||||
"$MODULE_DIR/scripts/stop.sh"
|
||||
cat "$OUT/i18n.txt"
|
||||
Reference in New Issue
Block a user