mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-12 06:06:10 +00:00
feat(api): give every error envelope a meta.errorCode
Roughly half of the refusals answered prose alone, so a client could branch on the code for one 404 and had to fall back to the status for the next. apiHandler now completes every error envelope with the status's generic http.* code when the route named none; a route's own code still wins. The family joins the published catalogue, and the profile form only shows a code's sentence when the code has one.
This commit is contained in:
1 parent
c7f69fc212
commit
fbbb535832
11 files changed
+219
-50
No files matched your search
@@ -55,7 +55,7 @@ import {
|
||||
} from "./sharing/record-session-fence";
|
||||
import { refuseOnKeyMismatch } from "./boot/key-mismatch-refusal";
|
||||
import { acceptIncomingRequestId } from "./http/request-id";
|
||||
import { withErrorRequestId } from "./api-response";
|
||||
import { withErrorEnvelopeDefaults } from "./api-response";
|
||||
import {
|
||||
capturedRateLimit,
|
||||
rateLimitResponseHeaders,
|
||||
@@ -365,9 +365,10 @@ export function apiHandler<T extends (...args: any[]) => Promise<Response>>(
|
||||
}
|
||||
}
|
||||
// Every error envelope names its request id in `meta.requestId`, so
|
||||
// the id survives a proxy that strips the header (see
|
||||
// `withErrorRequestId`).
|
||||
const nr = (await withErrorRequestId(
|
||||
// the id survives a proxy that strips the header, and carries a
|
||||
// `meta.errorCode`, the status's default when the route named none
|
||||
// (see `withErrorEnvelopeDefaults`).
|
||||
const nr = (await withErrorEnvelopeDefaults(
|
||||
response as Response,
|
||||
evt.getRequestId(),
|
||||
)) as NextResponse;
|
||||
|
||||
Reference in new issue
Block a user