forked from firebase/firebase-tools
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogError.ts
27 lines (25 loc) · 759 Bytes
/
logError.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { logger } from "./logger";
import * as clc from "colorette";
/* istanbul ignore next */
export function logError(error: any): void {
if (error.children && error.children.length) {
logger.error(clc.bold(clc.red("Error:")), clc.underline(error.message) + ":");
error.children.forEach((child: any) => {
let out = "- ";
if (child.name) {
out += clc.bold(child.name) + " ";
}
out += child.message;
logger.error(out);
});
} else {
if (error.original) {
logger.debug(error.original.stack);
}
logger.error();
logger.error(clc.bold(clc.red("Error:")), error.message);
}
if (error.context) {
logger.debug("Error Context:", JSON.stringify(error.context, undefined, 2));
}
}