open-standards/openpay/crates/op-payouts/src/error.rs
Transaction Science 7ef14c2ea9 ingest wave B: 3 crates · op-payouts + smart-byte-nostr + eoc-streaming
OpenPay (1 crate, 2174 LOC, 14 tests)
  op-payouts          Multi-rail payout engine. Visa Direct, Mastercard Send,
                      ACH credits (NACHA), Fedwire + SWIFT MT103 + ISO 20022
                      pacs.008, SEPA SCT + SCT Inst (mod-97 IBAN), UK FPS,
                      FedNow, RTP, PayPal, Wise. Crypto: USDC/USDT on
                      ETH/Polygon/Base/Solana + BTC + Lightning with real
                      ERC-20 transfer(address,uint256) calldata. Offline-pure
                      drivers (emit wire payloads — operators transmit).

Smart Byte (1 crate, 2605 LOC, 38 tests)
  smart-byte-nostr    Nostr adapter. NIP-01 canonical event id + BIP-340
                      Schnorr sign/verify; from-scratch bech32 + NIP-19 TLV
                      (npub/nsec/note/nprofile/nevent/nrelay); NIP-04 legacy
                      AES-256-CBC DMs; NIP-44 v2 HKDF-SHA256→ChaCha20+HMAC
                      with bucketed padding; NIP-17 gift-wrap (kind 1059) +
                      seal (kind 13) + rumor (kind 14); NIP-05/11/13/26/65.
                      Relay client message vocabulary (REQ/EVENT/CLOSE/AUTH/
                      EOSE/OK/NOTICE/CLOSED) + in-memory router.

EOC (1 crate, 2024 LOC, 30 tests)
  eoc-streaming       Token-by-token + tool-call streaming primitives.
                      SSE framing (data: lines); Anthropic event mapper
                      (message_start/content_block_*/message_delta/stop/ping);
                      OpenAI delta mapper; Vercel AI SDK mapper. Bounded-channel
                      backpressure with watermarks; CancelToken propagation;
                      Last-Event-ID resumable streams; per-stream joule meter.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
2026-05-24 13:39:09 -04:00

71 lines
2.3 KiB
Rust

//! Sealed error type for `op-payouts`.
use thiserror::Error;
/// Result alias for payout operations.
pub type Result<T> = core::result::Result<T, Error>;
/// All failure modes a payout driver can return.
#[derive(Debug, Error)]
pub enum Error {
/// Beneficiary account is structurally invalid (bad IBAN checksum,
/// non-numeric ABA, malformed crypto address, etc.).
#[error("invalid beneficiary account for {rail}: {detail}")]
InvalidBeneficiary {
/// Rail that rejected the account.
rail: &'static str,
/// Why the account is invalid.
detail: String,
},
/// The caller passed a [`PayoutMethod`](crate::PayoutMethod) variant
/// the active driver does not support (e.g. an IBAN to Visa Direct).
#[error("unsupported payout method for rail {rail}")]
UnsupportedMethod {
/// Rail name.
rail: &'static str,
},
/// Amount or currency outside this rail's allowed envelope (e.g.
/// non-EUR to SEPA, non-USD to FedNow, >$1M to RTP).
#[error("currency or amount limit violation on {rail}: {detail}")]
LimitViolation {
/// Rail name.
rail: &'static str,
/// Specific limit / mismatch text.
detail: String,
},
/// Beneficiary failed KYC screening (delegate to `op-screening`).
#[error("beneficiary KYC rejected: {0}")]
KycRejected(String),
/// Funding source is insufficient or unavailable.
#[error("funding error: {0}")]
Funding(String),
/// Network / transport failure when (a hypothetical) live transport
/// is wired in. Drivers in this crate are offline-pure; this variant
/// exists for downstream operators to surface their own failures.
#[error("transport error: {0}")]
Transport(String),
/// Rail returned a final reject. `code` is rail-specific.
#[error("rail rejected on {rail}: code={code}, message={message}")]
RailRejected {
/// Rail name.
rail: &'static str,
/// Rail-specific reject code.
code: String,
/// Human-readable message.
message: String,
},
/// Driver-side validation rejected before submission.
#[error("driver validation: {0}")]
DriverValidation(String),
/// Core layer error (Money, Currency).
#[error(transparent)]
Core(#[from] op_core::Error),
}