mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-24 04:16:00 +08:00
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:
committed by
Facebook Github Bot
parent
d67628eb5a
commit
534bbfac8f
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user