error.ts 682 B

123456789101112131415161718192021222324
  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)
  16. ? new ElementPlusError(`[${scope}] ${message}`)
  17. : scope
  18. // eslint-disable-next-line no-console
  19. console.warn(error)
  20. }
  21. }