Package-level declarations
| Entry point | Role |
|---|---|
| respondProblem | Respond with a problem document; fills status and instance from the call. |
| problemDetails | Inside install(StatusPages): build the exception-to-problem catalog. |
| ProblemDetailsCatalog | That catalog — map<T>, forStatusCode, standardStatusCodes, onUnmapped. |
| problemJson | Inside install(ContentNegotiation): register the JSON codec. |
| ProblemJsonConverter | The converter behind it, if you need to register it yourself. |
| ProblemContentTypes | application/problem+json and application/problem+xml as ContentType. |
Four behaviours here are decisions rather than defaults, and each is pinned by a test:
A problem document is always labelled
application/problem+json, even when it was matched underapplication/json. RFC 9457 §3 permits the override, and echoing backapplication/jsonwould strip the only wire-level marker saying the body is a problem document.instanceis filled fromrequest.path(), neverrequest.uri— the query string is left out because problem documents get logged on both ends and query strings carry tokens often enough that echoing them back by default is the wrong trade. Setinstanceexplicitly to include it.The catch-all handler rethrows
CancellationExceptionunless the status map claims it. A cancellation means the client is gone; answering it writes a document to a dead socket and logs a stack trace per dropped connection.TimeoutCancellationExceptionstill becomes a 504.A thrown
ProblemExceptionis answered with the document it carries, via an entry seeded into the catalog — somap<ProblemException>replaces it like any other. Itscause, when present, is logged server-side (errorfor a 5xx,debugotherwise) becauseStatusPageslogs nothing it handles and the cause would otherwise be dropped silently.
Types
The two media types RFC 9457 registers (§6.1): application/problem+json and application/problem+xml.
A declarative catalog of exception-to-problem and status-to-problem mappings.
Reads and writes application/problem+json bodies for ContentNegotiation.
Properties
An HttpStatusCode-typed view over ProblemType.status, which is a plain Int in core.
Functions
The about:blank problem for status, with the title taken from Ktor's own reason phrase.
Registers a ProblemDetailsCatalog against Ktor's own StatusPages configuration.
Registers the application/problem+json converter on Ktor's own ContentNegotiation.
Responds with problem, the problem itself deciding the HTTP status.