@@ -19,6 +19,80 @@ pub use mint::{MintAuthDatabase, MintAuthTransaction};
1919#[ cfg( feature = "wallet" ) ]
2020pub use wallet:: Database as WalletDatabase ;
2121
22+ /// Data conversion error
23+ #[ derive( thiserror:: Error , Debug ) ]
24+ pub enum ConversionError {
25+ /// Missing columns
26+ #[ error( "Not enough elements: expected {0}, got {1}" ) ]
27+ MissingColumn ( usize , usize ) ,
28+
29+ /// Missing parameter
30+ #[ error( "Missing parameter {0}" ) ]
31+ MissingParameter ( String ) ,
32+
33+ /// Invalid db type
34+ #[ error( "Invalid type from db, expected {0} got {1}" ) ]
35+ InvalidType ( String , String ) ,
36+
37+ /// Invalid data conversion in column
38+ #[ error( "Error converting {1}, expecting type {0}" ) ]
39+ InvalidConversion ( String , String ) ,
40+
41+ /// Mint Url Error
42+ #[ error( transparent) ]
43+ MintUrl ( #[ from] crate :: mint_url:: Error ) ,
44+
45+ /// NUT00 Error
46+ #[ error( transparent) ]
47+ CDKNUT00 ( #[ from] crate :: nuts:: nut00:: Error ) ,
48+
49+ /// NUT01 Error
50+ #[ error( transparent) ]
51+ CDKNUT01 ( #[ from] crate :: nuts:: nut01:: Error ) ,
52+
53+ /// NUT02 Error
54+ #[ error( transparent) ]
55+ CDKNUT02 ( #[ from] crate :: nuts:: nut02:: Error ) ,
56+
57+ /// NUT04 Error
58+ #[ error( transparent) ]
59+ CDKNUT04 ( #[ from] crate :: nuts:: nut04:: Error ) ,
60+
61+ /// NUT05 Error
62+ #[ error( transparent) ]
63+ CDKNUT05 ( #[ from] crate :: nuts:: nut05:: Error ) ,
64+
65+ /// NUT07 Error
66+ #[ error( transparent) ]
67+ CDKNUT07 ( #[ from] crate :: nuts:: nut07:: Error ) ,
68+
69+ /// NUT23 Error
70+ #[ error( transparent) ]
71+ CDKNUT23 ( #[ from] crate :: nuts:: nut23:: Error ) ,
72+
73+ /// Secret Error
74+ #[ error( transparent) ]
75+ CDKSECRET ( #[ from] crate :: secret:: Error ) ,
76+
77+ /// Serde Error
78+ #[ error( transparent) ]
79+ Serde ( #[ from] serde_json:: Error ) ,
80+
81+ /// BIP32 Error
82+ #[ error( transparent) ]
83+ BIP32 ( #[ from] bitcoin:: bip32:: Error ) ,
84+
85+ /// Generic error
86+ #[ error( transparent) ]
87+ Generic ( #[ from] Box < crate :: Error > ) ,
88+ }
89+
90+ impl From < crate :: Error > for ConversionError {
91+ fn from ( err : crate :: Error ) -> Self {
92+ ConversionError :: Generic ( Box :: new ( err) )
93+ }
94+ }
95+
2296/// CDK_database error
2397#[ derive( Debug , thiserror:: Error ) ]
2498pub enum Error {
@@ -39,6 +113,9 @@ pub enum Error {
39113 /// NUT00 Error
40114 #[ error( transparent) ]
41115 NUT00 ( #[ from] crate :: nuts:: nut00:: Error ) ,
116+ /// NUT01 Error
117+ #[ error( transparent) ]
118+ NUT01 ( #[ from] crate :: nuts:: nut01:: Error ) ,
42119 /// NUT02 Error
43120 #[ error( transparent) ]
44121 NUT02 ( #[ from] crate :: nuts:: nut02:: Error ) ,
@@ -68,6 +145,38 @@ pub enum Error {
68145 /// Invalid state transition
69146 #[ error( "Invalid state transition" ) ]
70147 InvalidStateTransition ( crate :: state:: Error ) ,
148+
149+ /// Invalid connection settings
150+ #[ error( "Invalid credentials {0}" ) ]
151+ InvalidConnectionSettings ( String ) ,
152+
153+ /// Unexpected database response
154+ #[ error( "Invalid database response" ) ]
155+ InvalidDbResponse ,
156+
157+ /// Internal error
158+ #[ error( "Internal {0}" ) ]
159+ Internal ( String ) ,
160+
161+ /// Data conversion error
162+ #[ error( transparent) ]
163+ Conversion ( #[ from] ConversionError ) ,
164+
165+ /// Missing Placeholder value
166+ #[ error( "Missing placeholder value {0}" ) ]
167+ MissingPlaceholder ( String ) ,
168+
169+ /// Unknown quote ttl
170+ #[ error( "Unknown quote ttl" ) ]
171+ UnknownQuoteTTL ,
172+
173+ /// Invalid UUID
174+ #[ error( "Invalid UUID: {0}" ) ]
175+ InvalidUuid ( String ) ,
176+
177+ /// QuoteNotFound
178+ #[ error( "Quote not found" ) ]
179+ QuoteNotFound ,
71180}
72181
73182#[ cfg( feature = "mint" ) ]
0 commit comments