Handle expected Prisma request errors (#1365) - #1367
Conversation
* Handle expected Prisma request errors
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Deployment failed with the following error: Learn More: https://vercel.link/multiple-function-regions |
Greptile SummaryThis PR refactors
Confidence Score: 5/5The change is safe to merge — it only affects logging behaviour and the Prisma error-code mapping; all response status codes and payloads are preserved or improved. The classification helpers are logically correct for every error branch, the new Prisma error-code paths (P2025, P2023-UUID, P2010) are all exercised by dedicated tests, and the console.warn breadcrumb satisfies the stated goal of keeping a visible trace without triggering Sentry alerts. No incorrect status codes, dropped error data, or broken contracts were found. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
E([Error thrown]) --> NE[normalizeError]
NE --> EP{isExpectedPrismaError?}
EP -- yes --> SL1{shouldLogError?}
EP -- no --> SL2{shouldLogError?}
SL1 -- yes\n5xx status --> CERR1[console.error]
SL1 -- no --> CWARN[console.warn\nbreadcrumb]
SL2 -- yes\nunexpected / 5xx --> CERR2[console.error]
SL2 -- no\nZod / APIError / CopilotApiError --> NOLOG[no log]
CERR1 --> RESP[NextResponse.json]
CWARN --> RESP
CERR2 --> RESP
NOLOG --> RESP
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
E([Error thrown]) --> NE[normalizeError]
NE --> EP{isExpectedPrismaError?}
EP -- yes --> SL1{shouldLogError?}
EP -- no --> SL2{shouldLogError?}
SL1 -- yes\n5xx status --> CERR1[console.error]
SL1 -- no --> CWARN[console.warn\nbreadcrumb]
SL2 -- yes\nunexpected / 5xx --> CERR2[console.error]
SL2 -- no\nZod / APIError / CopilotApiError --> NOLOG[no log]
CERR1 --> RESP[NextResponse.json]
CWARN --> RESP
CERR2 --> RESP
NOLOG --> RESP
Reviews (2): Last reviewed commit: "Warn on known Prisma errors instead of s..." | Re-trigger Greptile |
* Warn on known Prisma errors instead of silencing them
|
@greptileai I addressed your concern. Now we do console.warn on known errors. Re review the pr again. |
Uh oh!
There was an error while loading. Please reload this page.