mirror of
https://github.com/element-plus/element-plus.git
synced 2025-12-19 09:09:40 +08:00
* chore: only show warnings in dev mode * chore: test * chore: test2 * chore: test3 * chore: test3 * chore: update 4 * chore: update * chore: update * chore: update * chore: update Co-authored-by: btea <2356281422@qq.com> * chore: add security checks to all process --------- Co-authored-by: btea <2356281422@qq.com>
25 lines
716 B
TypeScript
25 lines
716 B
TypeScript
import { isString } from './types'
|
|
|
|
class ElementPlusError extends Error {
|
|
constructor(m: string) {
|
|
super(m)
|
|
this.name = 'ElementPlusError'
|
|
}
|
|
}
|
|
|
|
export function throwError(scope: string, m: string): never {
|
|
throw new ElementPlusError(`[${scope}] ${m}`)
|
|
}
|
|
|
|
export function debugWarn(err: Error): void
|
|
export function debugWarn(scope: string, message: string): void
|
|
export function debugWarn(scope: string | Error, message?: string): void {
|
|
if (typeof process !== 'undefined' && process.env.NODE_ENV !== 'production') {
|
|
const error: Error = isString(scope)
|
|
? new ElementPlusError(`[${scope}] ${message}`)
|
|
: scope
|
|
// eslint-disable-next-line no-console
|
|
console.warn(error)
|
|
}
|
|
}
|