error
Returns an error for all records that get passed to the processor.
Description
Any time a record is passed to this processor it returns an error, which results in the record being sent to the DLQ if it's configured, or the pipeline stopping.
Important: Make sure to add a condition to this processor, otherwise all records will trigger an error.
Configuration parameters
- YAML
- Table
version: 2.2
pipelines:
- id: example
status: running
connectors:
# define source and destination ...
processors:
- id: example
plugin: "error"
settings:
# Error message to be returned. This can be a Go
# [template](https://pkg.go.dev/text/template) executed on each
# [`Record`](https://pkg.go.dev/github.com/conduitio/conduit-commons/opencdc#Record)
# being processed.
# Type: string
message: "error processor triggered"
# Whether to decode the record key using its corresponding schema from
# the schema registry.
# Type: bool
sdk.schema.decode.key.enabled: "false"
# Whether to decode the record payload using its corresponding schema
# from the schema registry.
# Type: bool
sdk.schema.decode.payload.enabled: "false"
# Whether to encode the record key using its corresponding schema from
# the schema registry.
# Type: bool
sdk.schema.encode.key.enabled: "false"
# Whether to encode the record payload using its corresponding schema
# from the schema registry.
# Type: bool
sdk.schema.encode.payload.enabled: "false"
Name | Type | Default | Description |
---|---|---|---|
message | string | error processor triggered | Error message to be returned. This can be a Go template
executed on each |
sdk.schema.decode.key.enabled | bool | false | Whether to decode the record key using its corresponding schema from the schema registry. |
sdk.schema.decode.payload.enabled | bool | false | Whether to decode the record payload using its corresponding schema from the schema registry. |
sdk.schema.encode.key.enabled | bool | false | Whether to encode the record key using its corresponding schema from the schema registry. |
sdk.schema.encode.payload.enabled | bool | false | Whether to encode the record payload using its corresponding schema from the schema registry. |
Examples
Error record with custom error message
This example shows how to configure the error processor to return a custom error message for a record using a Go template.
Configuration parameters
- YAML
- Table
version: 2.2
pipelines:
- id: example
status: running
connectors:
# define source and destination ...
processors:
- id: example
plugin: "error"
settings:
message: "custom error message with data from record: {{.Metadata.foo}}"
Name | Value |
---|---|
message | custom error message with data from record: {{.Metadata.foo}} |
Record difference
Before | After | ||||
1 | { | 1 | { | ||
2 | - | "position": null, | 2 | + | "error": "custom error message with data from record: bar" |
3 | - | "operation": "create", | |||
4 | - | "metadata": { | |||
5 | - | "foo": "bar" | |||
6 | - | }, | |||
7 | - | "key": null, | |||
8 | - | "payload": { | |||
9 | - | "before": { | |||
10 | - | "bar": "baz" | |||
11 | - | }, | |||
12 | - | "after": { | |||
13 | - | "foo": "bar" | |||
14 | - | } | |||
15 | - | } | |||
16 | } | 3 | } |