Skip to content

Commit 155cae4

Browse files
authored
fix(crashlytics/ios): record stacktrace for JS errors (#177)
1 parent 8897266 commit 155cae4

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

packages/firebase-crashlytics/index.ios.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,9 @@ export class Crashlytics implements ICrashlytics {
6565
recordError(error: any): void {
6666
if (error instanceof Error) {
6767
StackTrace.fromError(error).then((stack) => {
68-
const traceElements = [];
69-
stack.forEach((item, i) => {
70-
traceElements[i] = FIRStackFrame.stackFrameWithSymbolFileLine(item.functionName || '(anonymous)', item.fileName, item.lineNumber);
71-
});
72-
const e = FIRExceptionModel.exceptionModelWithNameReason('JavaScriptError', error.message);
68+
const traceElements = stack.map((item) => FIRStackFrame.stackFrameWithSymbolFileLine(item.functionName || '(anonymous)', item.fileName ?? '', item.lineNumber ?? -1));
69+
const e = FIRExceptionModel.exceptionModelWithNameReason(error.name || 'JavaScriptError', error.message);
70+
e.stackTrace = NSArray.arrayWithArray(traceElements);
7371
this.native.recordExceptionModel(e);
7472
});
7573
} else {

0 commit comments

Comments
 (0)