25 lines
690 B
TypeScript
Raw Normal View History

2024-11-05 10:09:18 +08:00
import { isString } from '@vue/shared'
class TuniaoUIError extends Error {
constructor(message: string) {
super(message)
this.name = 'TuniaoUIError'
}
}
export function throwError(scope: string, msg: string): never {
throw new TuniaoUIError(`[${scope}] ${msg}`)
}
export function debugWarn(err: Error): void
export function debugWarn(scope: string, message: string): void
export function debugWarn(scope: string | Error, message?: string): void {
if (process.env.NODE_ENV !== 'production') {
const error: Error = isString(scope)
? new TuniaoUIError(`[${scope}] ${message}`)
: scope
// eslint-disable-next-line no-console
console.warn(error)
}
}