| 58 | const stackInfo = new SafeError(`callstack before invoking ${func.name || 'chrome API'}:`); |
| 59 | // A single parameter `result` is fine because we don't use API that return more |
| 60 | const cb = result => { |
| 61 | const runtimeErr = chrome.runtime.lastError; |
| 62 | const err = runtimeErr || ( |
| 63 | preprocessorFunc |
| 64 | ? preprocessorFunc(resolve, result) |
| 65 | : resolve(result) |
| 66 | ); |
| 67 | // Prefer `reject` over `throw` which stops debugger in 'pause on exceptions' mode |
| 68 | if (err) { |
| 69 | if (!runtimeErr) stackInfo[STACK] = `${err[1]}\n${stackInfo[STACK]}`; |
| 70 | stackInfo[MESSAGE] = runtimeErr ? err[MESSAGE] : `${err[0]}`; |
| 71 | stackInfo.isRuntime = !!runtimeErr; |
| 72 | reject(stackInfo); |
| 73 | } |
| 74 | }; |
| 75 | if (process.env.IS_INJECTED) { |
| 76 | safePush(args, cb); /* global safePush */ |
| 77 | try { |
no test coverage detected