UNPKG

@payai/x402

Version:

PayAI-distributed wrapper for @x402/core v2

68 lines (67 loc) 2.09 kB
// src/types/facilitator.ts var VerifyError = class extends Error { /** * Creates a VerifyError from a failed verification response. * * @param statusCode - HTTP status code from the facilitator * @param response - The verify response containing error details */ constructor(statusCode, response) { const reason = response.invalidReason || "unknown reason"; const message = response.invalidMessage; super(message ? `${reason}: ${message}` : reason); this.name = "VerifyError"; this.statusCode = statusCode; this.invalidReason = response.invalidReason; this.invalidMessage = response.invalidMessage; this.payer = response.payer; } }; var SettleError = class extends Error { /** * Creates a SettleError from a failed settlement response. * * @param statusCode - HTTP status code from the facilitator * @param response - The settle response containing error details */ constructor(statusCode, response) { const reason = response.errorReason || "unknown reason"; const message = response.errorMessage; super(message ? `${reason}: ${message}` : reason); this.name = "SettleError"; this.statusCode = statusCode; this.errorReason = response.errorReason; this.errorMessage = response.errorMessage; this.payer = response.payer; this.transaction = response.transaction; this.network = response.network; } }; var FacilitatorResponseError = class extends Error { /** * Creates a FacilitatorResponseError for malformed facilitator responses. * * @param message - The boundary error message */ constructor(message) { super(message); this.name = "FacilitatorResponseError"; } }; function getFacilitatorResponseError(error) { let current = error; while (current instanceof Error) { if (current instanceof FacilitatorResponseError) { return current; } current = current.cause; } return null; } export { VerifyError, SettleError, FacilitatorResponseError, getFacilitatorResponseError }; //# sourceMappingURL=chunk-VY72CEUI.mjs.map