-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Add Detailed Error Decoding Using decodeContractError
Problem
Currently, when a smart contract call fails, the SDK throws a generic or low-level error (e.g. execution reverted), which is not helpful for debugging or UX.
Proposed Solution
- Add a
decodeContractError(error)utility. - Use it across all contract interaction points in the SDK.
- Extract detailed messages like:
- Error reason (e.g.
Channel is already closed) - Related
channelId,payer, ormerchantif available.
- Error reason (e.g.
- Ensure the error is structured and readable.
Benefits
- Better Developer Experience: Developers get detailed, contextual error messages which make debugging faster and more straightforward.
- Improved User Feedback: User-facing applications can show clearer error messages, like "Channel is already closed," rather than generic or unclear revert messages.
- Easier Maintenance & Logging: Structured and tagged error messages allow for easier tracking, logging, and debugging, simplifying production monitoring.
- Standardized Error Handling: The
decodeContractErrorutility establishes a consistent and reusable error-handling pattern across all contract interactions in the SDK. - Extendable for Custom Errors: Future smart contract upgrades or changes can easily be supported by enhancing the error-decoding logic, especially if custom errors are used in contracts.
Example
try {
await contract.redeemChannel(channelId);
} catch (err) {
throw decodeContractError(err);
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working