1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
//! # Open Payments Client Error Types
//!
//! This module defines the error types used throughout the Open Payments client.
//! All client operations return a [`Result<T, OpClientError>`] which provides
//! detailed error information for different failure scenarios.
//!
//! ## Error Categories
//!
//! - **HTTP Errors**: Network and HTTP protocol errors
//! - **Parsing Errors**: Header, URL, and data parsing failures
//! - **Cryptographic Errors**: Key and signature-related issues
//! - **I/O Errors**: File system and network I/O problems
//!
//! ## Example Usage
//!
//! ```rust
//! use open_payments::client::{OpClientError, Result};
//!
//! fn handle_client_error(result: Result<()>) {
//! match result {
//! Ok(()) => println!("Operation successful"),
//! Err(OpClientError::Http(msg)) => eprintln!("HTTP error: {}", msg),
//! Err(OpClientError::Signature(msg)) => eprintln!("Signature error: {}", msg),
//! Err(OpClientError::Other(msg)) => eprintln!("Other error: {}", msg),
//! Err(e) => eprintln!("Unexpected error: {:?}", e),
//! }
//! }
//! ```
use Error;
/// Error type for Open Payments client operations.
///
/// This enum provides detailed error information for different types of failures
/// that can occur during client operations. Each variant includes context-specific
/// error messages to help with debugging and error handling.
///
/// ## Error Variants
///
/// - `Http` - Network and HTTP protocol errors
/// - `HeaderParse` - HTTP header parsing failures
/// - `Serde` - JSON serialization/deserialization errors
/// - `Io` - File system and I/O errors
/// - `Pem` - PEM format parsing errors
/// - `Pkcs8` - PKCS8 key format errors
/// - `Base64` - Base64 encoding/decoding errors
/// - `Url` - URL parsing errors
/// - `Signature` - Cryptographic signature errors
/// - `Other` - Miscellaneous errors
/// Result type for Open Payments client operations.
///
/// This is a type alias for `Result<T, OpClientError>` that provides a convenient
/// way to handle client operation results with detailed error information.
pub type Result<T> = Result;