ProblemType

interface ProblemType(source)

A problem type carrying the three things §4 asks a type author to define: a type URI, a title, and the HTTP status code to use with it. Implementing this interface states those three once, instead of restating them at every throw site.

ProblemType.title describes the type, so it is not overridable per problem. §3.1 asks it to stay constant except for localization, which is out of scope for v1. Only the detail and instance of ProblemType.problem vary per occurrence.

See also

Properties

Link copied to clipboard
abstract val status: Int

The HTTP status code to respond with for this type.

Link copied to clipboard
abstract val title: String

Short human-readable summary of this type, constant across occurrences (§3.1).

Link copied to clipboard
abstract val typeUri: String

The URI reference identifying this problem type: the document's type member.

Functions

Link copied to clipboard
fun ProblemType.exception(detail: String? = null, instance: String? = null, cause: Throwable? = null): ProblemException

Raises this problem type as a ProblemException.

Link copied to clipboard
fun ProblemType.problem(detail: String? = null, instance: String? = null): Problem

Builds a Problem for this type. detail and instance are the only per-occurrence fields.