@swell/cli
Version:
Swell's command line interface/utility
24 lines (19 loc) • 526 B
JavaScript
export function setupGlobalsTemplate() {
return `\
class SwellErrorImpl extends Error {
status: number;
constructor(message: string | object, options: { status?: number } = {}) {
const text =
typeof message === "string"
? message
: JSON.stringify(message, null, 2);
super(text);
this.name = "SwellError";
this.status = options.status ?? 500;
}
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(globalThis as any).SwellError = SwellErrorImpl;
export {};
`;
}