Report Java stack from errors from sync native module calls

Reviewed By: mhorowitz

Differential Revision: D5069794

fbshipit-source-id: ede314034a2eb6b063a22dbd6e5d13c8ad66e20c
This commit is contained in:
Pieter De Baets
2017-06-14 09:16:26 -07:00
committed by Facebook Github Bot
parent d67628eb5a
commit 534bbfac8f
10 changed files with 134 additions and 45 deletions

View File

@@ -18,20 +18,22 @@ export type StackFrame = {
methodName: string,
};
var stacktraceParser = require('stacktrace-parser');
export type ExtendedError = Error & {
framesToPop?: number,
};
function parseErrorStack(e: Error): Array<StackFrame> {
function parseErrorStack(e: ExtendedError): Array<StackFrame> {
if (!e || !e.stack) {
return [];
}
var stack = Array.isArray(e.stack) ? e.stack : stacktraceParser.parse(e.stack);
const stacktraceParser = require('stacktrace-parser');
const stack = Array.isArray(e.stack) ? e.stack : stacktraceParser.parse(e.stack);
var framesToPop = typeof e.framesToPop === 'number' ? e.framesToPop : 0;
let framesToPop = typeof e.framesToPop === 'number' ? e.framesToPop : 0;
while (framesToPop--) {
stack.shift();
}
return stack;
}