Class.CryptoError
Error thrown when a cryptographic operation fails.
Example
throw new CryptoError(CryptoErrorType.Encrypt, "Crypto.encrypt");
Extends
Constructors
Constructor
new CryptoError(
type: CryptoErrorType,
instance: string,
rootError?: Error): CryptoError;
Parameters
| Parameter | Type |
|---|---|
type | CryptoErrorType |
instance | string |
rootError? | Error |
Returns
CryptoError
Overrides
Properties
| Property | Modifier | Type | Default value | Description | Inherited from |
|---|---|---|---|---|---|
detail? | public | string | undefined | A human-readable explanation specific to this occurrence of the problem. This field helps the client understand and potentially correct the issue. Example error.detail // "The provided Ethereum address is not valid." | KeybanBaseError.detail |
instance | public | string | undefined | A URI reference that identifies the specific occurrence of the problem. This provides a unique identifier for the particular instance of the error. Example error.instance // "validateAddress-001" | KeybanBaseError.instance |
rootError? | public | Error | Record<string, unknown> | undefined | The original error instance, if any. This can be used to trace the root cause of the error. Example error.rootError // Original Error instance or additional error details | KeybanBaseError.rootError |
status? | public | number | undefined | The HTTP status code generated by the origin server for this occurrence of the problem. It is a numeric value and is included for the convenience of the client. Example error.status // 400 | KeybanBaseError.status |
timestamp | public | string | undefined | A timestamp recording the exact date and time when the exception occurred, in ISO8601 format (YYYY-MM-DDTHH:mm:ss.sssZ). Example error.timestamp // "2024-04-27T12:34:56.789Z" | KeybanBaseError.timestamp |
title | public | string | undefined | A short, human-readable summary of the problem type. It should remain consistent across occurrences of the problem except for localization purposes. Example error.title // "Invalid Ethereum Address" | KeybanBaseError.title |
type | public | CryptoErrorType | undefined | A URI reference that identifies the problem type. This property is mandatory and provides a machine-readable identifier for the error. Example error.type // "https://api.prod.keyban.io/errors/address-invalid" | KeybanBaseError.type |
types | static | typeof CryptoErrorType | CryptoErrorType | - | - |
Methods
toJSON()
toJSON(): {
detail: string | undefined;
instance: string;
rootError: Error | Record<string, unknown> | undefined;
status: number | undefined;
timestamp: string;
title: string;
type: CryptoErrorType;
};
Serializes the error instance into a JSON object, including all relevant properties. This is useful for logging, debugging, or transmitting error information.
Returns
{
detail: string | undefined;
instance: string;
rootError: Error | Record<string, unknown> | undefined;
status: number | undefined;
timestamp: string;
title: string;
type: CryptoErrorType;
}
- A JSON representation of the error.
detail
detail: string | undefined;
instance
instance: string;
rootError
rootError: Error | Record<string, unknown> | undefined;
status
status: number | undefined;
timestamp
timestamp: string;
title
title: string;
type
type: CryptoErrorType;
Example
const errorJson = error.toJSON();
console.log(errorJson);