mirror of
https://github.com/zhigang1992/now-deployment.git
synced 2026-04-11 11:19:32 +08:00
24 lines
578 B
TypeScript
24 lines
578 B
TypeScript
import chalk from 'chalk';
|
|
import { metrics, shouldCollectMetrics } from '../metrics';
|
|
|
|
const metric = metrics();
|
|
|
|
export default function error(
|
|
...input: string[] | [{ slug: string; message: string }]
|
|
) {
|
|
let messages = input;
|
|
if (typeof input[0] === 'object') {
|
|
const { slug, message } = input[0];
|
|
messages = [message];
|
|
if (slug) {
|
|
messages.push(`> More details: https://err.sh/now/${slug}`);
|
|
}
|
|
}
|
|
|
|
if (shouldCollectMetrics) {
|
|
metric.exception(messages.join('\n')).send();
|
|
}
|
|
|
|
return `${chalk.red('> Error!')} ${messages.join('\n')}`;
|
|
}
|