mirror of
https://github.com/developit/microbundle.git
synced 2026-01-18 13:56:35 +00:00
29 lines
644 B
JavaScript
29 lines
644 B
JavaScript
import { red, dim } from 'kleur';
|
|
import { stderr } from './utils';
|
|
|
|
export default function(err) {
|
|
const error = err.error || err;
|
|
const description = `${error.name ? error.name + ': ' : ''}${error.message ||
|
|
error}`;
|
|
const message = error.plugin
|
|
? `(${error.plugin} plugin) ${description}`
|
|
: description;
|
|
|
|
stderr(red().bold(message));
|
|
|
|
if (error.loc) {
|
|
stderr();
|
|
stderr(`at ${error.loc.file}:${error.loc.line}:${error.loc.column}`);
|
|
}
|
|
|
|
if (error.frame) {
|
|
stderr();
|
|
stderr(dim(error.frame));
|
|
} else if (err.stack) {
|
|
const headlessStack = error.stack.replace(message, '');
|
|
stderr(dim(headlessStack));
|
|
}
|
|
|
|
stderr();
|
|
}
|