Skip to content

Domain

domainHTTP 422Retrying the same request will not help

An error the schema declares for this operation, such as OutOfStock. It arrives with a type and its data.

Why it happens

  • The resolver threw one of the errors listed in the operation's throws. The error's type is its name in the schema, and data holds its fields.
  • Over a REST binding, the problem's type ends with that name, for example /errors/OutOfStock. The API you are calling defines it: look it up in that API's schema.

What to do

  • Handle it in the client by name: e.is("OutOfStock") in TypeScript, or the generated sealed class on the JVM.
  • A resolver may only throw errors the operation declares. Any other becomes internal, so add it to throws first.

What it looks like

Inside a batch, the operation's frame carries it:

json
{
  "id": 1,
  "error": {
    "code": "domain",
    "type": "OutOfStock",
    "data": {
      "bookId": "b1",
      "available": 1
    },
    "message": "Only 1 left"
  },
  "fin": true
}

When the whole request is refused over HTTP, the answer is a problem document:

json
{
  "type": "https://eddyboutros.github.io/rayfold/errors/domain",
  "title": "domain",
  "status": 422,
  "detail": "Only 1 left",
  "code": "domain"
}

See also all error types and the errors chapter of the specification.

Released under the Apache-2.0 license.