UNPKG

@baqhub/cli

Version:

The official command line interface for the BAQ federated app platform.

28 lines (27 loc) 704 B
import { CustomError } from "@baqhub/sdk"; export class ProgramError extends CustomError { message; options; constructor(message, options = {}) { super(message); this.message = message; this.options = options; } } export async function handleErrors(program, worker, genericError) { try { await worker(); } catch (error) { if (error instanceof ProgramError) { program.error(error.message, { code: error.options.code, exitCode: error.options.exitCode, }); } if (program.opts().debug) { throw error; } program.error(genericError); } }