Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function pretty(error) {
const { message, stack } = error;
const lines = getStackTraceLines(stack);
const topFrame = getTopFrame(lines);
const fallback = `${message}${stack}`;
if (!topFrame) {
return fallback;
}
const { file, line } = topFrame;
try {
const result = codeFrameColumns(
fs.readFileSync(file, 'utf8'),
{ start: { line } },
{ highlightCode: true }
);
return `\n${message}\n\n${result}\n${stack}\n`;
} catch (error) {