@rail402.dev/errors
v0.1.2
Published
Shared machine-readable error registry for the facilitator, Bazaar, and MCP server.
Readme
@rail402.dev/errors
The shared, machine-readable error registry used across the Rail402 facilitator, Bazaar, and MCP
server. Every rejection carries a stable code, a non-null human-legible reason, and a retryable
flag, so an agent can reason about a failure instead of parsing prose.
Install
npm install @rail402.dev/errorsUsage
import { X402Error, isErrorCode, ERROR_REGISTRY } from "@rail402.dev/errors";
try {
// ... a facilitator, Bazaar, or agent call ...
} catch (err) {
if (err instanceof X402Error) {
console.error(err.code, err.reason, err.retryable);
}
}
// Validate a code coming off the wire, or look one up:
isErrorCode("invalid_exact_stellar_payload_authorization_replayed"); // => true
ERROR_REGISTRY["invalid_exact_stellar_payload_authorization_replayed"].reason;Adding an error means adding it to the registry (never an inline string), so the set stays enumerable and documented.
Exports: X402Error, createError, isErrorCode, enrichUpstreamCode, ERROR_REGISTRY,
ALL_ERROR_CODES, and the ErrorCode type.
Part of Rail402. Apache-2.0.
