FailureProblems

class FailureProblems(statuses: ErrorStatuses, mappers: List<ProblemMapper> = emptyList(), catalog: Set<String> = emptySet())

The problem a route answers a failure with that is none of its own (#6510): the one step the application's routes (GlobalErrors), Wow's public routes and the query routes share, each keeping before it only what is its own (a service route's refusal, a query's error).

  1. What the framework knows: a ProblemException as its problem, a CommandRejectedException (a command a route sent through a CommandClient) as its result, a WowProblemException (another service's answer relayed, or the application's own) as its code, status, result and retry, a request that fails its constraints (a @Valid body's, a method's) as wow.request.invalid with its violations (RequestViolations), a request that cannot be read (ServerWebInputException: a body the codecs cannot read, a parameter missing or of the wrong type) as wow.request.malformed naming what does not read, any other ResponseStatusException as its status alone, a store that is unavailable (or a failure caused by one) as 503 wow.storage.unavailable, a body larger than the codecs take as 413, and a request whose connection closed before it was answered (Reactor Netty's AbortedException: a client that went away, a body that stalled past the read timeout, ReadTimeouts) as 400, logged at debug alone: no one reads that answer, and nothing failed on the server's side.

  2. Then the application's mappers, in order, for the failure and then each of its causes, but a cause that is one of the framework's own (the kinds of 1. it answers by themselves, frameworkOf): a mapper never sees one, even wrapped. The first problem one gives is the answer, as the host configures its code's status, once it passes the checks a mapped problem must (ProblemMapper); one that fails them is answered as no mapper's, logged once by the mapper and code. A mapper that throws is taken as one that does not know the failure, its failure logged.

  3. Else the branch's answer to an unexpected failure: by default a 500 that says nothing of its cause, which is logged.

A mapped code that no context's errors and no service route's errors of the Manifest list (its catalog) is answered all the same, and warned of once. What is logged once is remembered for at most MAX_LOGGED codes, since a mapper may build its codes from a downstream system's: past them, that is said once, and no more are logged.

Constructors

Link copied to clipboard
constructor(statuses: ErrorStatuses, mappers: List<ProblemMapper> = emptyList(), catalog: Set<String> = emptySet())

Types

Link copied to clipboard

Functions

Link copied to clipboard
fun problemOf(failure: Throwable, context: String? = null, unexpected: (Throwable) -> Problem = ::unexpected): Problem

The problem failure is answered with on a route of context (null outside one): what the framework knows, else the first mapper's, else unexpected's.