Skip to content

Instantly share code, notes, and snippets.

@sammyhenningsson
Last active October 11, 2020 19:01
Show Gist options
  • Save sammyhenningsson/049d10e2b8978059cde104fc5d6c2d52 to your computer and use it in GitHub Desktop.
Save sammyhenningsson/049d10e2b8978059cde104fc5d6c2d52 to your computer and use it in GitHub Desktop.
Specification of the shaf-error media type profile

The shaf-error media type profile

This profile describes a set of descriptors for generic error messages.

shaf-error descriptors

  • code: An identifier that describes the type of error.
  • title: A short string used for labeling the error.
  • message: A description with details about the error.
  • fields: An object with validation errors

Fields

An object describing validation errors. The keys correspond to attributes of a resource. The values are an array of strings describing validation errors for the corresponding attribute.

Examples:

{
  "title": "Invalid entity",
  "message": "The user could not be saved, due to unfulfilled requirements",
  "code": "VALIDATION_ERROR",
  "fields": {
    "email": ["cannot be empty"]
  }
}

or

{
  "title": "Unpermitted action",
  "message": "User is not allowed to edit this resource",
  "code": "FORBIDDEN_ERROR",
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment