Constructor
new Err(plugin, msg, …argsopt)
Constructor.
| Name | Type | Attributes | Description |
|---|---|---|---|
plugin | Plugin | Plugin instance | |
msg | string | Error message | |
args | * | <optional> <repeatable> | Variables to interpolate with error message. Error's payload can be pushed to the very last argument if needed |
- Source
Members
message :string
Translated message
- string
- Source
orgMessage :string
Original message before translation
- string
- Source
payload :Object
Error payload extracted from the last arguments, if any
- Object
- Source
Methods
fatal()
Print instance on console and terminate process.
- Source
formatErrorDetails(value) → {Object}
Pretty format error details. Used to format error payloads that contain details property, which is an array of error details.
Formatted error will be applied directly to the value parameter, and a detailsMessage will be returned for display purpose.
| Name | Type | Description |
|---|---|---|
value | Object | Value to format |
- Source
- Formatted result and details message
- Type:
- Object
write() → {Err}
Write message to the console. Chainable method, returns the Err instance itself.
If a payload is provided, it will be merged with the existing payload. If details is provided in the payload, it will be formatted and merged to the existing payload and a detailsMessage will be generated for display purpose.
Original message and translated message will be stored in orgMessage and message properties respectively.
ns property will be set to the plugin's namespace.
- Source
- Error object, useful for chaining
- Type:
- Err
Type Definitions
TErrDetails
Error details object type definition. This type is used to represent detailed information about an error, including the field that caused the error, the error message, the value that caused the error, and any additional context.
This type is particularly useful for validation errors, where you want to provide detailed feedback about what went wrong.
- Object
| Name | Type | Attributes | Description |
|---|---|---|---|
field | string | Field name | |
error | string | Error message | |
value | * | <optional> | The value that caused the error |
ext | Object | <optional> | Additional context about the error |
- Source