Files
xo-cash-utils/source/invitation/errors.ts
T
2026-10-05 12:59:22 +00:00

47 lines
1.3 KiB
TypeScript

/* eslint-disable max-classes-per-file */
/**
* Thrown when a value does not satisfy the XOInvitation schema.
*/
export class InvitationInvalidError extends Error {
constructor(details: string) {
const defaultMessage = `Invitation invalid, expected a value matching the XOInvitation type, but got: ${details}`;
super(defaultMessage);
this.name = 'InvitationInvalidError';
}
}
/**
* Thrown when invitation share JSON cannot be parsed.
*/
export class InvitationJsonMalformedError extends Error {
/**
* Parser failure forwarded from JSON parsing.
*/
readonly reason: string;
constructor(reason: string) {
const defaultMessage = `Invitation JSON malformed: expected a valid JSON string, but got: ${reason}`;
super(defaultMessage);
this.name = 'InvitationJsonMalformedError';
this.reason = reason;
}
}
/**
* Thrown when invitation serialization fails.
*/
export class InvitationSerializationFailedError extends Error {
/**
* Serializer failure forwarded from the serialization path.
*/
readonly reason: string;
constructor(reason: string) {
const defaultMessage = `Invitation serialization failed: ${reason}`;
super(defaultMessage);
this.name = 'InvitationSerializationFailedError';
this.reason = reason;
}
}