valia
Version:
A runtime data validator in TypeScript with advanced type inference, built-in validation functions, and seamless integration for server and client environments.
19 lines (16 loc) • 595 B
text/typescript
export class Issue extends Error {
print(context: string, message: string, plugin?: string) {
const red = "\x1b[31m", cyan = "\x1b[36m", gray = "\x1b[90m", reset = "\x1b[0m";
const emitter = "valia" + (plugin ? ":" + plugin : "");
const timestamp = new Date().toISOString();
console.log(
`${red}[ERROR]${reset} ${cyan}[${emitter}]${reset} ${gray}${timestamp}${reset}` +
`\nContext: ${context}` +
`\nMessage: ${message}`
);
}
constructor(context: string, message: string, plugin?: string) {
super(message);
this.print(context, message, plugin);
}
}