-
Notifications
You must be signed in to change notification settings - Fork 13
Use LdkServerError for error handling in all APIs. #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
f2e47f5
to
878b52e
Compare
| NodeError::ChannelCreationFailed | ||
| NodeError::ChannelClosingFailed | ||
| NodeError::ChannelConfigUpdateFailed | ||
| NodeError::DuplicatePayment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't looked through these exhaustively, but for BOLT11 DuplicatePayment
is returned if the user tries to pay an invoice with the same payment hash twice. So shouldn't it map to an InvalidRequestError
? Though for BOLT12 it would happen if we randomly generate the same payment id, which shouldn't happen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't mark DuplicatePayment
as invalid-request with certainty, it could be a legitimate race-condition on client side or idempotency failure.
Ideally, DuplicatePayment should become a sub-error within the lightning error category.
We typically use invalid-request for requests that can be safely ignored or can’t be fixed programmatically, but DuplicatePayment
might indicate a successful payment the client didn’t register.
LdkServerError::new( | ||
InvalidRequestError, | ||
"Address is not valid for LdkServer's configured network.".to_string(), | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need use the mapping here in order to provide a more specific error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, using the mapping makes the error less specific, since we can't customize the error message for specific scenario.
We use it where we can but provide more context by directly using LdkServerError
to be more helpful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I meant to say "not use" not "need use" lol.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Please squash.
d60055d
to
f795976
Compare
Squashed fixups. |
Use LdkServerError for error handling in all APIs.