ProblemBuilder

Builds a Problem. Obtain one through problem, which also supplies the Json that encodes the typed payloads handed to extension and extensions. That defaults to ProblemJson unless the caller overrides it.

Properties

Link copied to clipboard

A human-readable explanation of this occurrence (§3.1). Its job is helping the client correct the problem, and §3.1 asks consumers to leave it unparsed. Machine-readable data belongs in an extension member.

Link copied to clipboard

URI reference identifying this specific occurrence (§3.1). Need not be dereferenceable. problem-details-ktor fills it from the request path unless it is set here.

Link copied to clipboard
var status: Int?

The HTTP status code (§3.1). Advisory: the responder must make it agree with the actual response status, and nothing here checks that. problem-details-ktor fills it in from the response.

Link copied to clipboard

Short human-readable summary of the problem type (§3.1). It stays the same across occurrences.

Link copied to clipboard

The problem type URI (§3.1). Defaults to Problem.ABOUT_BLANK, which is what an absent type member means, so leaving it alone and setting it explicitly produce the same document. The type(ProblemType) overload sets it together with a type's title and status.

Functions

Link copied to clipboard
fun extension(name: String, value: ProblemValue)

Adds one extension member (§3.2), written as a sibling of the standard members, not nested under an extensions key.

fun extension(name: String, value: Boolean)

Adds a boolean extension member.

fun extension(name: String, value: Double)

Adds a floating-point extension member.

fun extension(name: String, value: Int)

Adds an integer extension member.

fun extension(name: String, value: Long)

Adds a 64-bit integer extension member.

fun extension(name: String, value: String)

Adds a string extension member, written quoted. "30" stays a string, not the number 30.

fun <T> extension(name: String, value: T, serializer: SerializationStrategy<T>)

Adds one extension member holding an arbitrary serializable value.

Link copied to clipboard
inline fun <T> ProblemBuilder.extension(name: String, value: T)

Adds one extension member holding an arbitrary @Serializable value, with the serializer resolved from T.

Link copied to clipboard
fun <T> extensions(value: T, serializer: SerializationStrategy<T>)

Spreads value's own properties into the problem as sibling extension members (§3.2). This is the typed producing edge, and value must serialize to a JSON object.

Link copied to clipboard
inline fun <T> ProblemBuilder.extensions(value: T)

Spreads value's own properties into the problem as sibling extension members, with the serializer resolved from T.

Link copied to clipboard
fun type(type: ProblemType)

Applies a ProblemType's type URI, title and status in one call.