Skip to content

Commit 3c3c133

Browse files
committed
Add error struct for LdkServerError.
1 parent 1b7abfb commit 3c3c133

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

server/src/api/error.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
pub(crate) struct LdkServerError {
2+
// The error message containing a generic description of the error condition in English.
3+
// It is intended for a human audience only and should not be parsed to extract any information
4+
// programmatically. Client-side code may use it for logging only.
5+
pub(crate) message: String,
6+
7+
// The error code uniquely identifying an error condition.
8+
// It is meant to be read and understood programmatically by code that detects/handles errors by
9+
// type.
10+
pub(crate) error_code: LdkServerErrorCode,
11+
}
12+
13+
pub(crate) enum LdkServerErrorCode {
14+
/// Please refer to [`protos::error::ErrorCode::InvalidRequestError`].
15+
InvalidRequestError,
16+
17+
/// Please refer to [`protos::error::ErrorCode::AuthError`].
18+
AuthError,
19+
20+
/// Please refer to [`protos::error::ErrorCode::LightningError`].
21+
LightningError,
22+
23+
/// Please refer to [`protos::error::ErrorCode::InternalServerError`].
24+
InternalServerError,
25+
}

server/src/api/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ pub(crate) mod bolt11_send;
33
pub(crate) mod bolt12_receive;
44
pub(crate) mod bolt12_send;
55
pub(crate) mod close_channel;
6+
pub(crate) mod error;
67
pub(crate) mod get_node_info;
78
pub(crate) mod get_payment_details;
89
pub(crate) mod list_channels;

0 commit comments

Comments
 (0)