PR #465 introduced a centralized error-handling pattern for /borrow routes:
- Service-level throws use named SDK error classes (e.g.
ProviderNotConfiguredError).
helpers/errors.ts:mapSdkError maps every known SDK error class to a structured HTTP status (400/403/404/410/422/503).
- A borrow-scoped
app.onError owns all error responses; no per-route try/catch survives.
packages/demo/backend/src/services/lend.ts and packages/demo/backend/src/services/swap.ts still use the old pattern:
throw new Error('Wallet not found') / throw new Error('Swap not configured for this wallet') — unrecognized by mapSdkError, surfaces as opaque 500.
- Inline
try { ... } catch (err) { console.error(...); throw err } blocks (lend.ts:34-70, swap.ts:93-113).
Acceptance
PR #465 introduced a centralized error-handling pattern for
/borrowroutes:ProviderNotConfiguredError).helpers/errors.ts:mapSdkErrormaps every known SDK error class to a structured HTTP status (400/403/404/410/422/503).app.onErrorowns all error responses; no per-routetry/catchsurvives.packages/demo/backend/src/services/lend.tsandpackages/demo/backend/src/services/swap.tsstill use the old pattern:throw new Error('Wallet not found')/throw new Error('Swap not configured for this wallet')— unrecognized bymapSdkError, surfaces as opaque 500.try { ... } catch (err) { console.error(...); throw err }blocks (lend.ts:34-70, swap.ts:93-113).Acceptance
Error(...)throws inservices/lend.tsandservices/swap.tswith named SDK error classes or new local named classes (e.g.WalletNotFoundError).helpers/errors.ts:mapSdkErrormapping table to cover the new classes (and any SDK error classes lend/swap can throw that aren't already mapped).app.ts:77borrow-scopedonErrorto also handle/lend,/swap,/wallet/lend,/wallet/swap(or generalize the scoping).try/catchblocks in lend.ts and swap.ts.app.onErrorend-to-end.