element-plus/packages/utils-v2/error.ts

18 lines
460 B
TypeScript
Raw Normal View History

2020-08-19 11:05:40 +08:00
class ElementPlusError extends Error {
constructor(m: string) {
super(m)
2020-09-14 10:03:33 +08:00
this.name = 'ElementPlusError'
2020-08-19 11:05:40 +08:00
}
}
export function throwError(scope: string, m: string): never {
2020-09-14 10:03:33 +08:00
throw new ElementPlusError(`[${scope}] ${m}`)
}
export function debugWarn(scope: string, message: string): void {
if (process.env.NODE_ENV !== 'production') {
// eslint-disable-next-line no-console
console.warn(new ElementPlusError(`[${scope}] ${message}`))
}
2020-08-19 11:05:40 +08:00
}