MCPcopy Index your code
hub / github.com/ether/etherpad / stringifyException

Function stringifyException

src/tests/frontend/runner.js:6–24  ·  view source on GitHub ↗
(exception)

Source from the content-addressed store, hash-verified

4// async function for some bizarre reason, so the async function is wrapped in a non-async function.
5$(() => (async () => {
6 const stringifyException = (exception) => {
7 let err = exception.stack || exception.toString();
8
9 // FF / Opera do not add the message
10 if (!~err.indexOf(exception.message)) {
11 err = `${exception.message}\n${err}`;
12 }
13
14 // <=IE7 stringifies to [Object Error]. Since it can be overloaded, we
15 // check for the result of the stringifying.
16 if (err === '[object Error]') err = exception.message;
17
18 // Safari doesn't give you a stack. Let's at least provide a source line.
19 if (!exception.stack && exception.sourceURL && exception.line !== undefined) {
20 err += `\n(${exception.sourceURL}:${exception.line})`;
21 }
22
23 return err;
24 };
25
26 const customRunner = (runner) => {
27 const stats = {suites: 0, tests: 0, passes: 0, pending: 0, failures: 0};

Callers 1

customRunnerFunction · 0.85

Calls 1

toStringMethod · 0.45

Tested by

no test coverage detected