feat: structured error categories for external failures#1
Open
jaydenkalu wants to merge 1 commit into
Open
Conversation
…oe#493) - Add AppError class with category, httpStatus, retriable properties - Add ErrorCategory enum: STELLAR_TIMEOUT, STELLAR_CIRCUIT, STELLAR_RPC, DB_QUERY, DB_CONSTRAINT, VALIDATION, UNAUTHORIZED, INTERNAL - Add errorBody() helper for consistent {error, code, retriable} API responses - Update stellar.ts: use AppError instead of raw errors, add structured logging - Update queue.ts: log error category on job failures for observability - Update readings route: use AppError/errorBody for DB errors Closes AnnabelJoe#493
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.
Closes AnnabelJoe#493
Summary
Adds a typed
AppErrorsystem so API routes and the job processor return consistent, actionable error responses.Changes
src/lib/errors.ts(new):AppError,ErrorCategoryenum,errorBody()helperSTELLAR_TIMEOUT,STELLAR_CIRCUIT,STELLAR_RPC,DB_QUERY,DB_CONSTRAINT,VALIDATION,UNAUTHORIZED,INTERNALhttpStatusandretriableflag so clients can distinguish transient vs fatalsrc/lib/stellar.ts: throwsAppErrorinstead of raw errors; replacesconsole.errorwithlogger.warn/errorincluding error categorysrc/lib/queue.ts: logscategoryfield on anchor/mint job failuressrc/app/api/readings/route.ts: DB insert error usesAppError(DB_QUERY)+errorBody()API response shape
{ "error": "...", "code": "STELLAR_TIMEOUT", "retriable": true }Testing