feat: production-ready error handling (prefixed codes, domain errors, global filter, structured logging) - #14
Merged
Conversation
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
CHARGE_NOT_FOUND→AE01,IDEMPOTENCY_CONFLICT→AE02,INVALID_STATE_TRANSITION→AE03,WEBHOOK_EVENT_ALREADY_PROCESSED→AE04, mais dois novos:AE05(UNKNOWN_EVENT_TYPE) eAE06(MISSING_IDEMPOTENCY_KEY), eIE01(INTERNAL_ERROR) para erros inesperadosUnknownEventTypeErroreMissingIdempotencyKeyErrorsubstituemthrow new Error(...)ethrow new BadRequestException(...)hardcodedlogger.warncomwhat,why(code),how(method + url),error_classemessage{ statusCode: 500, code: "IE01", message: "Internal server error" }— zero vazamento de detalhes internosCreateChargeServiceeProcessWebhookServicerelançamDomainErrorsem log (o filter cuida) e logam + relançam erros inesperados com contexto (charge_id,event_id)domain-errors.spec.ts,domain-exception.filter.spec.ts), testes e2e atualizados — 102 testes passandoTest plan
npm test— 102 passed, 0 failednpm run build— build limpo, sem erros TypeScriptcodeno formatoAExx(ex:AE01para 404,AE02para 422){ statusCode: 500, code: "IE01", message: "Internal server error" }sem vazar detalheslevel: warn, campowhycom o código ehowcomMETHOD /path