${statusCode ? `${statusCode}: ` : ""}${title}
${body || `Path: ${escape(pathname)}
`}
import { N as NOOP_MIDDLEWARE_HEADER, D as DEFAULT_404_COMPONENT } from './astro/server_DrnzQWw3.mjs'; import { parse } from 'devalue'; import { escape } from 'html-escaper'; const NOOP_MIDDLEWARE_FN = async (_ctx, next) => { const response = await next(); response.headers.set(NOOP_MIDDLEWARE_HEADER, "true"); return response; }; const ACTION_QUERY_PARAMS = { actionName: "_astroAction"}; const __vite_import_meta_env__ = {"ASSETS_PREFIX": undefined, "BASE_URL": "/", "DEV": false, "MODE": "production", "PROD": true, "SITE": undefined, "SSR": true}; const codeToStatusMap = { // Implemented from tRPC error code table // https://trpc.io/docs/server/error-handling#error-codes BAD_REQUEST: 400, UNAUTHORIZED: 401, FORBIDDEN: 403, NOT_FOUND: 404, TIMEOUT: 405, CONFLICT: 409, PRECONDITION_FAILED: 412, PAYLOAD_TOO_LARGE: 413, UNSUPPORTED_MEDIA_TYPE: 415, UNPROCESSABLE_CONTENT: 422, TOO_MANY_REQUESTS: 429, CLIENT_CLOSED_REQUEST: 499, INTERNAL_SERVER_ERROR: 500 }; const statusToCodeMap = Object.entries(codeToStatusMap).reduce( // reverse the key-value pairs (acc, [key, value]) => ({ ...acc, [value]: key }), {} ); class ActionError extends Error { type = "AstroActionError"; code = "INTERNAL_SERVER_ERROR"; status = 500; constructor(params) { super(params.message); this.code = params.code; this.status = ActionError.codeToStatus(params.code); if (params.stack) { this.stack = params.stack; } } static codeToStatus(code) { return codeToStatusMap[code]; } static statusToCode(status) { return statusToCodeMap[status] ?? "INTERNAL_SERVER_ERROR"; } static fromJson(body) { if (isInputError(body)) { return new ActionInputError(body.issues); } if (isActionError(body)) { return new ActionError(body); } return new ActionError({ code: "INTERNAL_SERVER_ERROR" }); } } function isActionError(error) { return typeof error === "object" && error != null && "type" in error && error.type === "AstroActionError"; } function isInputError(error) { return typeof error === "object" && error != null && "type" in error && error.type === "AstroActionInputError" && "issues" in error && Array.isArray(error.issues); } class ActionInputError extends ActionError { type = "AstroActionInputError"; // We don't expose all ZodError properties. // Not all properties will serialize from server to client, // and we don't want to import the full ZodError object into the client. issues; fields; constructor(issues) { super({ message: `Failed to validate: ${JSON.stringify(issues, null, 2)}`, code: "BAD_REQUEST" }); this.issues = issues; this.fields = {}; for (const issue of issues) { if (issue.path.length > 0) { const key = issue.path[0].toString(); this.fields[key] ??= []; this.fields[key]?.push(issue.message); } } } } function getActionQueryString(name) { const searchParams = new URLSearchParams({ [ACTION_QUERY_PARAMS.actionName]: name }); return `?${searchParams.toString()}`; } function deserializeActionResult(res) { if (res.type === "error") { let json; try { json = JSON.parse(res.body); } catch { return { data: void 0, error: new ActionError({ message: res.body, code: "INTERNAL_SERVER_ERROR" }) }; } if (Object.assign(__vite_import_meta_env__, { _: process.env._ })?.PROD) { return { error: ActionError.fromJson(json), data: void 0 }; } else { const error = ActionError.fromJson(json); error.stack = actionResultErrorStack.get(); return { error, data: void 0 }; } } if (res.type === "empty") { return { data: void 0, error: void 0 }; } return { data: parse(res.body, { URL: (href) => new URL(href) }), error: void 0 }; } const actionResultErrorStack = /* @__PURE__ */ function actionResultErrorStackFn() { let errorStack; return { set(stack) { errorStack = stack; }, get() { return errorStack; } }; }(); function template({ title, pathname, statusCode = 404, tabTitle, body }) { return `
Path: ${escape(pathname)}
`}