ProblemDetailsCatalog

A declarative catalog of exception-to-problem and status-to-problem mappings.

Every entry becomes exactly one registration on Ktor's own StatusPages configuration; dispatch, including nearest-parent-class resolution, stays StatusPages's job. Obtain one through problemDetails, or through problemCatalog when something besides StatusPages needs it too. Configuration is limited to the builder block. Once returned, a catalog is immutable, so every consumer observes the same mappings.

Properties

Link copied to clipboard

The problem types declared through map with a ProblemType argument, in declaration order.

Link copied to clipboard

The status codes registered through forStatusCode, including via standardStatusCodes. The returned set is a snapshot and cannot change this catalog.

Functions

Link copied to clipboard

Registers handler, run on every problem this catalog produces right before it is sent.

Link copied to clipboard

Registers a problem body for one status code.

Link copied to clipboard
inline fun <T : Throwable> map(noinline toProblem: (ApplicationCall, T) -> Problem)

Maps T to a problem built from the call and the exception.

inline fun <T : Throwable> map(type: ProblemType, noinline detailFrom: (T) -> String? = { it.message })

Maps T to type, taking detail from the exception message by default.

Link copied to clipboard

Replaces the problem produced for an exception no mapping covers.

Link copied to clipboard

Covers the codes Ktor itself generates without an explicit body: 404, 405, 406, 415.