Repository navigation
feat(core): add shared API error type for packages and apps - #373
Open
huangji6693-max wants to merge 1 commit into
Open
huangji6693-max wants to merge 1 commit into
huangji6693-max wants to merge 1 commit into
Conversation
|
@huangji6693-max is attempting to deploy a commit to the Isaac Gellu's projects Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 49 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
10 tasks
This branch has not been deployed
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 #311
Defines and exports a shared, serializable API error contract (
ApiErrorPayload,ApiErrorCode,createApiErrorPayload,isApiErrorPayload,toUnknownApiErrorPayload, andnormalizeClientError) in@chenaikit/coreand adopts it across backend and frontend error-handling paths.Changes Included
packages/core/src/errors.ts&packages/core/src/index.ts:ApiErrorPayload(error,message, optionalstatusCode,requestId,details,retryAfter) andAPI_ERROR_CODES/ApiErrorCode.createApiErrorPayloadandsanitizeErrorDetailsto omitundefinedproperties and strip sensitive keys (stack,stackTrace,cause,sql,raw,password,secret,token,authorization) before serialization.isApiErrorPayloadtype guard so SDK and application consumers can narrow structured API error responses safely.toUnknownApiErrorPayloadandnormalizeClientErrorso unexpected failures are converted into safe user-facing payloads without leaking raw internals.packages/core/test/core.test.ts:apps/backend/src/middleware/errorHandler.ts&apps/backend/src/middleware/errorHandler.test.ts:ApiErrorPayload,createApiErrorPayload, andtoUnknownApiErrorPayloadfrom@chenaikit/coreinbuildErrorBodyand the 500 fallback handler, with test assertions verifyingisApiErrorPayload(res.body).apps/frontend/src/components/ErrorBoundary.tsx&apps/frontend/src/components/ErrorBoundary.test.tsx:normalizeClientErrorfrom@chenaikit/coreto safely render structured API error messages and optionalRequest IDmetadata in the error boundary fallback UI.Testing done
pnpm --filter @chenaikit/core run lint && pnpm --filter @chenaikit/core run test && pnpm --filter @chenaikit/core run buildcd apps/backend && pnpm run lint && pnpm exec tsc -p tsconfig.json --noEmit && pnpm run test && pnpm run buildcd apps/frontend && npm run lint && npx --no-install tsc --noEmit && npm run test && npx --no-install vite buildScreenshots
N/A — internal error-handling normalization and optional
Request ID: <id>diagnostic line inErrorBoundaryfallback alert verified via React Testing Library (apps/frontend/src/components/ErrorBoundary.test.tsx).Checklist
@chenaikit/coreisApiErrorPayloadandnormalizeClientError