Couper Documentation

edge

Error Handler

The error_handler block lets you configure the handling of errors thrown in components configured by the parent blocks.

The error handler label specifies which error type should be handled. Multiple labels are allowed. The label can be omitted to catch all relevant errors. This has the same behavior as the error type *, that catches all errors explicitly.

Concerning child blocks and attributes, the error_handler block is similar to an Endpoint Block.

Block nameContextLabel
error_handlerAPI Block, Endpoint Block, Basic Auth Block, JWT Block, OAuth2 AC (Beta) Block, OIDC Block, SAML Blockoptional

Example

basic_auth "ba" {
  # ...
  error_handler "basic_auth_credentials_missing" {
    response {
      status = 403
      json_body = {
        error = "forbidden"
      }
    }
  }
}

Attributes

NameTypeDefaultDescription
add_form_params
object
-

Key/value pairs to add form parameters to the upstream request body.

add_query_params
object
-

Key/value pairs to add query parameters to the upstream request URL.

add_request_headers
object
-

Key/value pairs to add as request headers in the upstream request.

add_response_headers
object
-

Key/value pairs to add as response headers in the client response.

custom_log_fields
object
-

Log fields for custom logging. Inherited by nested blocks.

error_file
string
-

Location of the error file template.

remove_form_params
object
-

List of names to remove form parameters from the upstream request body.

remove_query_params
tuple (string)
[]

List of names to remove query parameters from the upstream request URL.

remove_request_headers
tuple (string)
[]

List of names to remove headers from the upstream request.

remove_response_headers
tuple (string)
[]

List of names to remove headers from the client response.

set_form_params
object
-

Key/value pairs to set query parameters in the upstream request URL.

set_query_params
object
-

Key/value pairs to set query parameters in the upstream request URL.

set_request_headers
object
-

Key/value pairs to set as request headers in the upstream request.

set_response_headers
object
-

Key/value pairs to set as response headers in the client response.

Nested Blocks

NameDescription
proxy

Configures a proxy (zero or more).

request

Configures a request (zero or more).

response

Configures the response (zero or one).