fix: don't store codeframe on error object (#1898)

This commit is contained in:
Marvin Hagemeister
2023-10-10 15:03:22 +02:00
committed by GitHub
parent 500336e97d
commit bc89844ea7
4 changed files with 13 additions and 6 deletions
+5 -4
View File
@@ -792,6 +792,7 @@ export class ServerContext {
// deno-lint-ignore no-explicit-any
ctx?: any,
error?: unknown,
codeFrame?: string,
) => {
return async (data?: Data, options?: RenderOptions) => {
if (route.component === undefined) {
@@ -819,6 +820,7 @@ export class ServerContext {
data,
state: ctx?.state,
error,
codeFrame,
});
if (resp instanceof Response) {
@@ -905,14 +907,13 @@ export class ServerContext {
"%cAn error occurred during route handling or page rendering.",
"color:red",
);
let codeFrame: string | undefined;
if (this.#dev && error instanceof Error) {
const codeFrame = await getCodeFrame(error);
codeFrame = await getCodeFrame(error);
if (codeFrame) {
console.error();
console.error(codeFrame);
// deno-lint-ignore no-explicit-any
(error as any).codeFrame = codeFrame;
}
}
console.error(error);
@@ -922,7 +923,7 @@ export class ServerContext {
{
...ctx,
error,
render: errorHandlerRender(req, {}, ctx, error),
render: errorHandlerRender(req, {}, ctx, error, codeFrame),
},
);
};