Skip to main content

bsv/primitives/
error.rs

1//! Error types for the primitives module.
2
3use thiserror::Error;
4
5/// Unified error type for all primitive operations.
6#[derive(Debug, Error)]
7pub enum PrimitivesError {
8    #[error("invalid hex: {0}")]
9    InvalidHex(String),
10
11    #[error("invalid DER: {0}")]
12    InvalidDer(String),
13
14    #[error("invalid WIF: {0}")]
15    InvalidWif(String),
16
17    #[error("point not on curve")]
18    PointNotOnCurve,
19
20    #[error("invalid private key: {0}")]
21    InvalidPrivateKey(String),
22
23    #[error("invalid public key: {0}")]
24    InvalidPublicKey(String),
25
26    #[error("invalid signature: {0}")]
27    InvalidSignature(String),
28
29    #[error("decryption failed")]
30    DecryptionFailed,
31
32    #[error("invalid padding")]
33    InvalidPadding,
34
35    #[error("checksum mismatch")]
36    ChecksumMismatch,
37
38    #[error("insufficient entropy")]
39    InsufficientEntropy,
40
41    #[error("arithmetic error: {0}")]
42    ArithmeticError(String),
43
44    #[error("threshold error: {0}")]
45    ThresholdError(String),
46
47    #[error("division by zero")]
48    DivisionByZero,
49
50    #[error("invalid length: {0}")]
51    InvalidLength(String),
52
53    #[error("invalid format: {0}")]
54    InvalidFormat(String),
55}