open-standards/openpay/crates/op-subscriptions/src/error.rs
Transaction Science 70ecd6caa0 Initial import — three open standards under one shelf
Transaction Science open standards monorepo. Each subdirectory is a
self-contained reference protocol with its own README and licence.

- openpay/    Apache-2.0  payment-acceptance stack (Rust, 26 crates)
- smart-byte/ CC-BY-4.0   content-addressed value carrier (spec)
- eoc/        CC-BY-4.0   energy-optimised compute (spec)

The wire format and the right to fork are public. The optional hosted
services are the offer; the protocols are not.
2026-05-23 07:58:09 -04:00

45 lines
1.1 KiB
Rust

//! Sealed error type.
use thiserror::Error;
/// Crate `Result` alias.
pub type Result<T> = core::result::Result<T, Error>;
/// All failure modes.
#[derive(Debug, Error, Clone, PartialEq, Eq)]
pub enum Error {
/// Caller-supplied input violated a precondition.
#[error("invalid: {0}")]
Invalid(String),
/// Lookup missed.
#[error("subscription not found: {0}")]
NotFound(String),
/// State-machine transition refused.
#[error("invalid transition: subscription {id} is in {state}")]
InvalidTransition {
/// Subscription id.
id: String,
/// Current state.
state: String,
},
/// Idempotency replay with mismatched body.
#[error("idempotency mismatch on external_id `{0}`")]
IdempotencyMismatch(String),
/// Currency mismatch between plan amount and an operation
/// (e.g. proration credit in a different currency).
#[error("currency mismatch: {a} vs {b}")]
CurrencyMismatch {
/// One side.
a: String,
/// Other side.
b: String,
},
/// Forwarded `op-core` error.
#[error(transparent)]
Core(#[from] op_core::Error),
}