Skip to content

Conversation

@nepet
Copy link
Member

@nepet nepet commented Jun 19, 2025

This PR introduces a comprehensive error handling framework for trampoline payments, replacing generic anyhow::Error usage with strongly-typed, domain-specific errors. The error handling provides better error categorization, improved diagnostics, and seamless gRPC integration. It also adds rich error context with hints for developers and users while surviving serialization into gRPC statuses for usage across service boundaries.

@nepet nepet force-pushed the 2524-538-improve-trampoline-errors branch 2 times, most recently from bc74d44 to 70581bd Compare June 20, 2025 13:37
@nepet nepet requested a review from cdecker June 20, 2025 14:10
@cdecker
Copy link
Collaborator

cdecker commented Jun 22, 2025

Very nice changes. I'd just like to move the error into a separate module, so we don't make tramp public (if we were to do that, we should change the name to the full trampoline too, the abbreviated version has ... meanings).

cdecker
cdecker previously approved these changes Jul 6, 2025
Copy link
Collaborator

@cdecker cdecker left a comment

Choose a reason for hiding this comment

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

Looking very good now 👍

@nepet is this good to go?

@cdecker cdecker enabled auto-merge (rebase) July 16, 2025 09:18
nepet added 7 commits July 16, 2025 11:21
Introduces a custom error module, providing a comprehensive error
handling system. The module offers a generic, extensible approach
to error management with rich context.

Key features:
- Generic GreenlightError<C> type that works with custom error
  codes
- Seamless conversion between custom errors and tonic::Status
- Structured error details with JSON serialization for gRPC
  transport
- User-friendly messages with optional hints for resolution

The framework enables consistent error handling across services
while maintaining gRPC compatibility and providing detailed error
information for both users and developers.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
Migrates from generic anyhow::Error to strongly-typed
TrampolineError	throughout the trampoline_pay implementation.
This provides better error categorization and improved diagnostics.

Changes:
- Implement TrampolineError using the greenlight_error framework
- Define TrampolineErrCode enum with specific error cases (42701-42714)
- Add conversion from CLN RPC errors with code preservation
- Replace all anyhow::Error usage with appropriate TrampolineError types
- Add convenience constructors for common error scenarios

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
In order to access the TrampolineError from the internal gl plugin
we need to make it public.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
When hitting an error on trampoline_pay we just reported a generic
status UNKNOWN to the caller. This commit wires the actual status
trhough. This allows the caller to receive a detailed explaination of
the underlying error that caused the failed payment.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
We wan't to be able to use the error framework across diferent
greenlight crates. The util crate is a good place to store some common
functionalities.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
@cdecker cdecker force-pushed the 2524-538-improve-trampoline-errors branch from 79c0ff8 to caf1005 Compare July 16, 2025 09:22
@cdecker
Copy link
Collaborator

cdecker commented Jul 16, 2025

Rebased and going to merge asap. This likely forces us to make the next update a major version bump, but that's ok, we're getting new functionality with it.

@cdecker cdecker merged commit 38c3b84 into main Jul 16, 2025
11 checks passed
@cdecker cdecker deleted the 2524-538-improve-trampoline-errors branch July 16, 2025 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants