Skip to main content

ppoppo_sdk_core/
error.rs

1//! sdk-core's local error type.
2//!
3//! Distinct from `pas_external::error::Error` — sdk-core does not depend
4//! on pas-external. Carrying its own minimal error makes the dependency
5//! direction one-way (pas-external → sdk-core, never the reverse).
6//!
7//! Variants stay narrow: anything sdk-core's primitive types
8//! (`Ppnum::TryFrom`, `JwksCache::fetch`) can fail with. SDK-side
9//! aggregations (OAuth flows, refresh-token cipher, etc.) live in
10//! `pas-external::error::Error` and absorb `SdkCoreError` via
11//! `From<SdkCoreError> for Error` at the seam.
12//!
13//! Phase A scope (audit-revised 2026-05-08): `InvalidPpnum` is the only
14//! variant lifted from pas-external during the types::* migration. Future
15//! sdk-core surfaces that need typed errors (jwks cache, discovery) reach
16//! this enum or carry their own narrow types co-located with the surface.
17
18#[derive(Debug, thiserror::Error)]
19#[non_exhaustive]
20pub enum SdkCoreError {
21    /// `Ppnum::try_from(String)` rejected a value that does not match
22    /// the `^[0-9]{11,}$` invariant. Carries the offending input for
23    /// audit logs; the consumer routes to `400 BAD_REQUEST`.
24    #[error("invalid ppnum: {0}")]
25    InvalidPpnum(String),
26}