Skip to main content

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

ParameterType
typeCryptoErrorType
instancestring
rootError?Error

Returns

CryptoError

Overrides

KeybanBaseError.constructor

Properties

PropertyModifierTypeDefault valueDescriptionInherited from
detail?publicstringundefinedA 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
instancepublicstringundefinedA 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?publicError | Record<string, unknown>undefinedThe 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 detailsKeybanBaseError.rootError
status?publicnumberundefinedThe 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 // 400KeybanBaseError.status
timestamppublicstringundefinedA 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
titlepublicstringundefinedA 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
typepublicCryptoErrorTypeundefinedA 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
typesstatictypeof CryptoErrorTypeCryptoErrorType--

Methods

toJSON()

toJSON(): {
detail: undefined | string;
instance: string;
rootError: undefined | Error | Record<string, unknown>;
status: undefined | number;
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: undefined | string;
instance: string;
rootError: undefined | Error | Record<string, unknown>;
status: undefined | number;
timestamp: string;
title: string;
type: CryptoErrorType;
}
  • A JSON representation of the error.
NameType
detailundefined | string
instancestring
rootErrorundefined | Error | Record<string, unknown>
statusundefined | number
timestampstring
titlestring
typeCryptoErrorType

Example

const errorJson = error.toJSON();
console.log(errorJson);

Inherited from

KeybanBaseError.toJSON