task: normalize Soroban RPC errors to stable API codes for /api/billing/deduct#372
Open
icodeBisola wants to merge 1 commit into
Open
task: normalize Soroban RPC errors to stable API codes for /api/billing/deduct#372icodeBisola wants to merge 1 commit into
icodeBisola wants to merge 1 commit into
Conversation
- Add SorobanRpcError class with SorobanRpcErrorCategory type to sorobanBilling.ts - Classify RPC failures: INSUFFICIENT_BALANCE → 402, TIMEOUT → 504, CONTRACT_ERROR/NETWORK_ERROR → 502 - Update /api/billing/deduct handler to map SorobanRpcError categories to PaymentRequiredError, GatewayTimeoutError, BadGatewayError - Add 7 tests covering all error categories (12 total, all passing) Closes CalloraOrg#319
|
@icodeBisola Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #319
Maps Soroban RPC failures in
sorobanBilling.tsto stable error types so/api/billing/deductalways returns predictable HTTP status codes.Changes
src/services/sorobanBilling.tsSorobanRpcErrorCategorytype:INSUFFICIENT_BALANCE | TIMEOUT | CONTRACT_ERROR | NETWORK_ERRORSorobanRpcErrorclass (extendsError) carrying acategoryfieldclassifyError(message)helper that maps error message keywords to categoriesinvoke()now produceSorobanRpcErrorwith the correct category (HTTP errors →NETWORK_ERROR, missing result →NETWORK_ERROR, simulation errors → classified by message, abort/timeout →TIMEOUT)src/routes/billing.tsSorobanRpcError,BadGatewayError,GatewayTimeoutError/deductcatch block mapsSorobanRpcErrorcategories:INSUFFICIENT_BALANCE→PaymentRequiredError(402)TIMEOUT→GatewayTimeoutError(504)CONTRACT_ERROR/NETWORK_ERROR→BadGatewayError(502)result.success === falseblock also maps error message keywords to the same stable codessrc/services/sorobanBilling.test.tsSorobanRpcErrorcategoriesAcceptance Criteria
INSUFFICIENT_BALANCESOROBAN_RPC_TIMEOUTSOROBAN_RPC_ERRORSOROBAN_RPC_ERRORTest Output