Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const printActualErrorMessage = error => {
if (error) {
const {message, stack} = separateMessageFromStack(error.stack);
return (
'Instead, it threw:\n' +
/* eslint-disable-next-line new-cap */
RECEIVED_COLOR(
` ${message}` +
formatStackTrace(
// remove KaTeX internal stack entries
stack.split('\n')
.filter(line => line.indexOf('new ParseError') === -1)
.join('\n'),
{
rootDir: process.cwd(),
testMatch: [],
},
{
noStackTrace: false,
const formatError = (error: string | ErrorWithCode): SerializableError => {
if (typeof error === 'string') {
const {message, stack} = separateMessageFromStack(error);
return {
message,
stack,
type: 'Error',
};
}
return {
code: error.code || undefined,
message: error.message,
stack: error.stack,
type: 'Error',
};
};
Error.prepareStackTrace = (error, trace) => {
const prepared = prepareStackTrace
? separateMessageFromStack(prepareStackTrace(error, trace))
: error;
const transformed = transform ? transform(prepared) : prepared;
return pretty(transformed);
};
}