Errors
Typed validation errors raised while builders materialize or explicit payload validation runs. Every subclass includes a machine-readable category and a path identifying the invalid field.
ErrorCategory
type ErrorCategory =
| "length-exceeded"
| "out-of-range"
| "mutually-exclusive"
| "type-mismatch"
| "missing-required"
| "invalid-usage";
Stable machine-readable category attached to every validation error.
InvalidUsageError
Base class for invalid Block Kit input.
Catch this class to handle every slackblocks validation failure, or catch a subclass when the reason matters to application behavior.
Extends
Error
Extended by
Constructors
Constructor
new InvalidUsageError(path, message): InvalidUsageError;
Creates a validation error.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | string | Dot-and-index path to the invalid field. |
message | string | Human-readable explanation of the constraint. |
Returns
Overrides
Error.constructor
Properties
| Property | Modifier | Type | Default value | Description |
|---|---|---|---|---|
category | readonly | ErrorCategory | "invalid-usage" | Machine-readable failure category. |
path | readonly | string | undefined | Dot-and-index path to the invalid payload field. |
LengthError
A string, array, or collection falls outside a field's allowed length. Typical causes include text exceeding Slack's limit, too many options, or an action identifier longer than 255 characters.
Extends
Constructors
Constructor
new LengthError(path, message): LengthError;
Creates a validation error.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | string | Dot-and-index path to the invalid field. |
message | string | Human-readable explanation of the constraint. |
Returns
Inherited from
Properties
| Property | Modifier | Type | Description | Overrides |
|---|---|---|---|---|
category | readonly | "length-exceeded" | Machine-readable failure category. | InvalidUsageError.category |
path | readonly | string | Dot-and-index path to the invalid payload field. | - |
MissingRequiredError
A required field or one-of requirement is not satisfied. Typical causes include building a section without text or fields, or creating a conversation filter without any filter options.
Extends
Constructors
Constructor
new MissingRequiredError(path, message): MissingRequiredError;
Creates a validation error.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | string | Dot-and-index path to the invalid field. |
message | string | Human-readable explanation of the constraint. |
Returns
Inherited from
Properties
| Property | Modifier | Type | Description | Overrides |
|---|---|---|---|---|
category | readonly | "missing-required" | Machine-readable failure category. | InvalidUsageError.category |
path | readonly | string | Dot-and-index path to the invalid payload field. | - |
MutualExclusivityError
Mutually exclusive fields are supplied together. Examples include combining an image URL with a Slack file, or providing both options and option groups to a static select menu.
Extends
Constructors
Constructor
new MutualExclusivityError(path, message): MutualExclusivityError;
Creates a validation error.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | string | Dot-and-index path to the invalid field. |
message | string | Human-readable explanation of the constraint. |
Returns
Inherited from
Properties
| Property | Modifier | Type | Description | Overrides |
|---|---|---|---|---|
category | readonly | "mutually-exclusive" | Machine-readable failure category. | InvalidUsageError.category |
path | readonly | string | Dot-and-index path to the invalid payload field. | - |
OutOfRangeError
A numeric value falls outside a field's allowed range. Typical causes include minimum values greater than maximum values or counts outside Slack's supported bounds.
Extends
Constructors
Constructor
new OutOfRangeError(path, message): OutOfRangeError;
Creates a validation error.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | string | Dot-and-index path to the invalid field. |
message | string | Human-readable explanation of the constraint. |
Returns
Inherited from
Properties
| Property | Modifier | Type | Description | Overrides |
|---|---|---|---|---|
category | readonly | "out-of-range" | Machine-readable failure category. | InvalidUsageError.category |
path | readonly | string | Dot-and-index path to the invalid payload field. | - |
TypeMismatchError
A payload field or nested object has the wrong runtime type or an unsupported discrete value. The error path identifies the exact field that failed runtime validation.
Extends
Constructors
Constructor
new TypeMismatchError(path, message): TypeMismatchError;
Creates a validation error.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | string | Dot-and-index path to the invalid field. |
message | string | Human-readable explanation of the constraint. |
Returns
Inherited from
Properties
| Property | Modifier | Type | Description | Overrides |
|---|---|---|---|---|
category | readonly | "type-mismatch" | Machine-readable failure category. | InvalidUsageError.category |
path | readonly | string | Dot-and-index path to the invalid payload field. | - |