Skip to content

Commit

Permalink
fix(app): convert NativeFirebaseError.getStackWithMessage to static t…
Browse files Browse the repository at this point in the history
…o fix crash (#4619)

* change instance method to static method to avoid fatal error while parsing error
* http error
* lint errors

Co-authored-by: blashadow <blackzerogamer@gmail.com>
  • Loading branch information
mikehardy and BlaShadow authored Nov 26, 2020
1 parent 6fb1f77 commit 090b0bb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
9 changes: 6 additions & 3 deletions packages/app/lib/internal/NativeFirebaseError.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ export default class NativeFirebaseError extends Error {
value: userInfo.nativeErrorMessage || null,
});

this.stack = this.getStackWithMessage(`NativeFirebaseError: ${this.message}`);
this.stack = NativeFirebaseError.getStackWithMessage(
`NativeFirebaseError: ${this.message}`,
this.jsStack,
);

// Unused
// this.nativeStackIOS = nativeError.nativeStackIOS;
Expand All @@ -71,7 +74,7 @@ export default class NativeFirebaseError extends Error {
*
* @returns {string}
*/
getStackWithMessage(message) {
return [message, ...this.jsStack.split('\n').slice(2, 13)].join('\n');
static getStackWithMessage(message, jsStack) {
return [message, ...jsStack.split('\n').slice(2, 13)].join('\n');
}
}
7 changes: 6 additions & 1 deletion packages/functions/lib/HttpsError.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*
*/

import { NativeFirebaseError } from '@react-native-firebase/app/lib/internal';

export default class HttpsError extends Error {
constructor(code, message, details, nativeErrorInstance) {
super(message);
Expand All @@ -34,6 +36,9 @@ export default class HttpsError extends Error {
value: message,
});

this.stack = nativeErrorInstance.getStackWithMessage(`Error: ${this.message}`);
this.stack = NativeFirebaseError.getStackWithMessage(
`Error: ${this.message}`,
nativeErrorInstance.jsStack,
);
}
}

1 comment on commit 090b0bb

@vercel
Copy link

@vercel vercel bot commented on 090b0bb Nov 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.