fix: don't store codeframe on error object (#1898)
This commit is contained in:
@@ -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),
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user