summaryrefslogtreecommitdiff
path: root/cli/js/error_stack.ts
diff options
context:
space:
mode:
authorNayeem Rahman <nayeemrmn99@gmail.com>2020-04-13 15:54:16 +0100
committerGitHub <noreply@github.com>2020-04-13 10:54:16 -0400
commit0ea6eb83a906bff543be4c3301f23444986b022b (patch)
tree923e5b1c7608839c9a7be545f8973ae751ee7e73 /cli/js/error_stack.ts
parent5105c6839904f35351481137160459fdc2edadd2 (diff)
refactor(core/js_error): Align JSStackFrame with CallSite (#4715)
Renames and adds missing fields to JSStackFrame from CallSite. Fixes #4705. Cleans up base changes for line and column numbers.
Diffstat (limited to 'cli/js/error_stack.ts')
-rw-r--r--cli/js/error_stack.ts55
1 files changed, 26 insertions, 29 deletions
diff --git a/cli/js/error_stack.ts b/cli/js/error_stack.ts
index 43723dff6..e77f0865c 100644
--- a/cli/js/error_stack.ts
+++ b/cli/js/error_stack.ts
@@ -11,31 +11,31 @@ function patchCallSite(callSite: CallSite, location: Location): CallSite {
getThis(): unknown {
return callSite.getThis();
},
- getTypeName(): string {
+ getTypeName(): string | null {
return callSite.getTypeName();
},
- getFunction(): Function {
+ getFunction(): Function | null {
return callSite.getFunction();
},
- getFunctionName(): string {
+ getFunctionName(): string | null {
return callSite.getFunctionName();
},
- getMethodName(): string {
+ getMethodName(): string | null {
return callSite.getMethodName();
},
- getFileName(): string {
- return location.filename;
+ getFileName(): string | null {
+ return location.fileName;
},
getLineNumber(): number {
- return location.line;
+ return location.lineNumber;
},
getColumnNumber(): number {
- return location.column;
+ return location.columnNumber;
},
getEvalOrigin(): string | null {
return callSite.getEvalOrigin();
},
- isToplevel(): boolean {
+ isToplevel(): boolean | null {
return callSite.isToplevel();
},
isEval(): boolean {
@@ -176,15 +176,15 @@ function callSiteToString(callSite: CallSite, isInternal = false): string {
interface CallSiteEval {
this: unknown;
- typeName: string;
- function: Function;
- functionName: string;
- methodName: string;
- fileName: string;
+ typeName: string | null;
+ function: Function | null;
+ functionName: string | null;
+ methodName: string | null;
+ fileName: string | null;
lineNumber: number | null;
columnNumber: number | null;
evalOrigin: string | null;
- isToplevel: boolean;
+ isToplevel: boolean | null;
isEval: boolean;
isNative: boolean;
isConstructor: boolean;
@@ -227,16 +227,16 @@ function prepareStackTrace(
structuredStackTrace
.map(
(callSite): CallSite => {
- const filename = callSite.getFileName();
- const line = callSite.getLineNumber();
- const column = callSite.getColumnNumber();
- if (filename && line != null && column != null) {
+ const fileName = callSite.getFileName();
+ const lineNumber = callSite.getLineNumber();
+ const columnNumber = callSite.getColumnNumber();
+ if (fileName && lineNumber != null && columnNumber != null) {
return patchCallSite(
callSite,
applySourceMap({
- filename,
- line,
- column,
+ fileName,
+ lineNumber,
+ columnNumber,
})
);
}
@@ -244,16 +244,13 @@ function prepareStackTrace(
}
)
.map((callSite): string => {
+ // @ts-ignore
+ error.__callSiteEvals.push(Object.freeze(evaluateCallSite(callSite)));
const isInternal =
callSite.getFileName()?.startsWith("$deno$") ?? false;
const string = callSiteToString(callSite, isInternal);
- const callSiteEv = Object.freeze(evaluateCallSite(callSite));
- if (callSiteEv.lineNumber != null && callSiteEv.columnNumber != null) {
- // @ts-ignore
- error.__callSiteEvals.push(callSiteEv);
- // @ts-ignore
- error.__formattedFrames.push(string);
- }
+ // @ts-ignore
+ error.__formattedFrames.push(string);
return ` at ${colors.stripColor(string)}`;
})
.join("\n");