MCPcopy Create free account
hub / github.com/deepnote/vscode-deepnote / formatException

Function formatException

src/test/web/customReporter.ts:119–142  ·  view source on GitHub ↗
(err: any)

Source from the content-addressed store, hash-verified

117 }
118}
119function formatException(err: any) {
120 const props = ['actual', 'expected', 'operator', 'generatedMessage'];
121 let message = '';
122 if (typeof err.inspect === 'function') {
123 message = err.inspect() + '';
124 } else if (err.message && typeof err.message.toString === 'function') {
125 message = err.message + '';
126 }
127 const error: Record<string, any> = {
128 name: err.name,
129 message,
130 stack: err.stack,
131 showDiff: err.showDiff,
132 inspect: ''
133 };
134 props.forEach((prop) => {
135 try {
136 error[prop] = JSON.parse(JSON.stringify(err[prop]));
137 } catch {
138 error[prop] = '<..?..>';
139 }
140 });
141 return error as Exception;
142}
143
144/**
145 * We use this to hijack all of the console output, so we have all of the output generated when a test fails.

Callers 1

CustomReporterFunction · 0.85

Calls 3

parseMethod · 0.65
inspectMethod · 0.45
forEachMethod · 0.45

Tested by

no test coverage detected