(rootStack: ParsedStackFrame[], hook: HookLogEntry)
| 934 | } |
| 935 | |
| 936 | function parseTrimmedStack(rootStack: ParsedStackFrame[], hook: HookLogEntry) { |
| 937 | // Get the stack trace between the primitive hook function and |
| 938 | // the root function call. I.e. the stack frames of custom hooks. |
| 939 | const hookStack = ErrorStackParser.parse(hook.stackError); |
| 940 | const rootIndex = findCommonAncestorIndex(rootStack, hookStack); |
| 941 | const primitiveIndex = findPrimitiveIndex(hookStack, hook); |
| 942 | if ( |
| 943 | rootIndex === -1 || |
| 944 | primitiveIndex === -1 || |
| 945 | rootIndex - primitiveIndex < 2 |
| 946 | ) { |
| 947 | if (primitiveIndex === -1) { |
| 948 | // Something went wrong. Give up. |
| 949 | return [null, null]; |
| 950 | } else { |
| 951 | return [hookStack[primitiveIndex - 1], null]; |
| 952 | } |
| 953 | } |
| 954 | return [ |
| 955 | hookStack[primitiveIndex - 1], |
| 956 | hookStack.slice(primitiveIndex, rootIndex - 1), |
| 957 | ]; |
| 958 | } |
| 959 | |
| 960 | function parseHookName(functionName: void | string): string { |
| 961 | if (!functionName) { |
no test coverage detected