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:
Salakar 2017-03-17 15:41:25 +00:00
parent 24738dd03f
commit 46c84581ca
1 changed files with 19 additions and 3 deletions

View File

@ -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 {