EASYAIuniappNewUI/node_modules/@tuniao/tnui-vue3-uniapp/utils/error.ts
2025-02-08 18:50:38 +08:00

25 lines
690 B
TypeScript

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)
}
}