error.ts 369 B

123456789101112131415
  1. import k from "kleur";
  2. /**
  3. * Logs an internal error
  4. * @param msg Short error message
  5. * @param err Error instance that caused the error
  6. * @param fatal Exits with code 1 if set to true
  7. */
  8. export function error(msg: string, err?: Error, fatal = false) {
  9. console.error("\n");
  10. console.error(k.red(msg));
  11. err && console.error(err);
  12. fatal && process.exit(1);
  13. }