Skip to content

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

Merged
merged 24 commits into from
Feb 28, 2025

Conversation

G8XSU
Copy link
Contributor

@G8XSU G8XSU commented Feb 26, 2025

Use LdkServerError for error handling in all APIs.

@G8XSU G8XSU requested a review from jkczyz February 27, 2025 00:38
@G8XSU G8XSU force-pushed the 25-02-error-handling branch from f2e47f5 to 878b52e Compare February 27, 2025 00:39
@G8XSU G8XSU marked this pull request as ready for review February 27, 2025 00:40
@G8XSU G8XSU mentioned this pull request Feb 27, 2025
13 tasks
@G8XSU G8XSU added the Weekly Goal Someone wants to land this this week label Feb 27, 2025
| NodeError::ChannelCreationFailed
| NodeError::ChannelClosingFailed
| NodeError::ChannelConfigUpdateFailed
| NodeError::DuplicatePayment
Copy link

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.

Copy link
Contributor Author

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.

Comment on lines +17 to +20
LdkServerError::new(
InvalidRequestError,
"Address is not valid for LdkServer's configured network.".to_string(),
)
Copy link

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?

Copy link
Contributor Author

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.

Copy link

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.

@G8XSU G8XSU requested a review from jkczyz February 28, 2025 19:56
Copy link

@jkczyz jkczyz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Please squash.

@G8XSU G8XSU force-pushed the 25-02-error-handling branch from d60055d to f795976 Compare February 28, 2025 20:40
@G8XSU
Copy link
Contributor Author

G8XSU commented Feb 28, 2025

Squashed fixups.

@G8XSU G8XSU merged commit b70ab5b into lightningdevkit:main Feb 28, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Weekly Goal Someone wants to land this this week
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants