mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2024-11-11 04:07:34 +03:00
Add getStackTrace
This commit is contained in:
parent
f18ef4e66e
commit
04673cb032
|
@ -28,7 +28,8 @@
|
||||||
"prefer-template": 0,
|
"prefer-template": 0,
|
||||||
"prefer-rest-params": 0,
|
"prefer-rest-params": 0,
|
||||||
"no-proto": 0,
|
"no-proto": 0,
|
||||||
"no-underscore-dangle": 0
|
"no-underscore-dangle": 0,
|
||||||
|
"max-len": ["error", { "code": 120 }]
|
||||||
},
|
},
|
||||||
"plugins": [
|
"plugins": [
|
||||||
"react"
|
"react"
|
||||||
|
|
|
@ -128,3 +128,32 @@ export function getSeralizeParameter(config, param) {
|
||||||
if (typeof serializeState === 'function') return { replacer: value };
|
if (typeof serializeState === 'function') return { replacer: value };
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getStackTrace(config, toExcludeFromTrace) {
|
||||||
|
if (!config.trace) return undefined;
|
||||||
|
if (typeof config.trace === 'function') return config.trace();
|
||||||
|
|
||||||
|
let stack;
|
||||||
|
let extraFrames = 0;
|
||||||
|
let prevStackTraceLimit;
|
||||||
|
const traceLimit = config.traceLimit;
|
||||||
|
const error = Error();
|
||||||
|
if (Error.captureStackTrace) {
|
||||||
|
if (Error.stackTraceLimit < traceLimit) {
|
||||||
|
prevStackTraceLimit = Error.stackTraceLimit;
|
||||||
|
Error.stackTraceLimit = traceLimit;
|
||||||
|
}
|
||||||
|
Error.captureStackTrace(error, toExcludeFromTrace);
|
||||||
|
} else {
|
||||||
|
extraFrames = 3;
|
||||||
|
}
|
||||||
|
stack = error.stack;
|
||||||
|
if (prevStackTraceLimit) Error.stackTraceLimit = prevStackTraceLimit;
|
||||||
|
if (extraFrames || typeof Error.stackTraceLimit !== 'number' || Error.stackTraceLimit > traceLimit) {
|
||||||
|
const frames = stack.split('\n');
|
||||||
|
if (frames.length > traceLimit) {
|
||||||
|
stack = frames.slice(0, traceLimit + extraFrames + (frames[0] === 'Error' ? 1 : 0)).join('\n');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user