firebase.crash().report() now accepts an error instead of a string, a string version of the error is generated before sending to native side.
This commit is contained in:
parent
24738dd03f
commit
46c84581ca
|
@ -30,10 +30,26 @@ export default class Analytics extends Base {
|
|||
* exceptions where recovery is not possible.
|
||||
* NOTE: on iOS, this will cause the app to crash as it's the only way to ensure the exception
|
||||
* gets sent to Firebase. Otherwise it just gets lost as a log message.
|
||||
* @param {string} message
|
||||
* @param {Error} error
|
||||
* @param maxStackSize
|
||||
*/
|
||||
report(message: string): void {
|
||||
FirebaseCrash.report(message);
|
||||
report(error: Error, maxStackSize: Number = 10): void {
|
||||
if (!error || !error.code || !error.message) return;
|
||||
|
||||
let errorMessage = `Message: ${error.message}\r\n`;
|
||||
|
||||
if (error.code) {
|
||||
errorMessage = `${errorMessage}Code: ${error.code}\r\n`;
|
||||
}
|
||||
|
||||
const stackRows = error.stack.split('\n');
|
||||
errorMessage = `${errorMessage}\r\nStack: \r\n`;
|
||||
for (let i = 0, len = stackRows.length; i < len; i++) {
|
||||
if (i === maxStackSize) break;
|
||||
errorMessage = `${errorMessage} - ${stackRows[i]}\r\n`;
|
||||
}
|
||||
|
||||
FirebaseCrash.report(errorMessage);
|
||||
}
|
||||
|
||||
get namespace(): string {
|
||||
|
|
Loading…
Reference in New Issue