error.ts 700 B

12345678910111213141516171819202122
  1. import { isString } from './types'
  2. class ElementPlusError extends Error {
  3. constructor(m: string) {
  4. super(m)
  5. this.name = 'ElementPlusError'
  6. }
  7. }
  8. export function throwError(scope: string, m: string): never {
  9. throw new ElementPlusError(`[${scope}] ${m}`)
  10. }
  11. export function debugWarn(err: Error): void
  12. export function debugWarn(scope: string, message: string): void
  13. export function debugWarn(scope: string | Error, message?: string): void {
  14. if (process.env.NODE_ENV !== 'production') {
  15. const error: Error = isString(scope) ? new ElementPlusError(`[${scope}] ${message}`) : scope
  16. // eslint-disable-next-line no-console
  17. console.warn(error)
  18. }
  19. }