getErrorFromCode
●errors · /index·function
Maps a GenericErrorKind or ApiErrorKind code to its corresponding error class, enabling reconstruction of typed errors from serialized codes.
Signature
function getErrorFromCode(code: ApiErrorKind | GenericErrorKind): typeof ApiError | typeof GenericError;Parameters
| Name | Type | Description |
|---|---|---|
code | ApiErrorKind | GenericErrorKind |
Returns
The error class constructor for the code, or null when the code is not recognized.
Example
const ErrorClass = getErrorFromCode(ApiErrorKind.API_UNKNOWN_SHOP_DOMAIN);
if (ErrorClass) throw new ErrorClass();Related
ApiErrorKind GenericErrorKind ApiError CartNotFoundError CartProviderError CartUserError ConvexOperatorTokenMintError DomainVerificationError