mirror of
https://github.com/developit/microbundle.git
synced 2026-01-25 14:06:50 +00:00
29 lines
653 B
JavaScript
29 lines
653 B
JavaScript
import chalk from 'chalk';
|
|
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(chalk.bold.red(message));
|
|
|
|
if (error.loc) {
|
|
stderr();
|
|
stderr(`at ${error.loc.file}:${error.loc.line}:${error.loc.column}`);
|
|
}
|
|
|
|
if (error.frame) {
|
|
stderr();
|
|
stderr(chalk.dim(error.frame));
|
|
} else if (err.stack) {
|
|
const headlessStack = error.stack.replace(message, '');
|
|
stderr(chalk.dim(headlessStack));
|
|
}
|
|
|
|
stderr();
|
|
}
|