/
githubmirror
/
nest
Обзор
Документация
Войти
/
githubmirror
/
nest
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
packages/websockets/errors/ws-exception.ts
27 строк
699 B
Kamil Myśliwiec
build: use strict null checks part 5
26 ноя 2024, 16:39
Не верифицирован
26 ноя 2024, 16:39
7d3e5c1
Код
Авторство
О чём код?
import { isObject, isString } from '@nestjs/common/utils/shared.utils'; export class WsException extends Error { constructor(private readonly error: string | object) { super(); this.initMessage(); } public initMessage() { if (isString(this.error)) { this.message = this.error; } else if ( isObject(this.error) && isString((this.error as Record<string, any>).message) ) { this.message = (this.error as Record<string, any>).message; } else if (this.constructor) { this.message = this.constructor.name .match(/[A-Z][a-z]+|[0-9]+/g)! .join(' '); } } public getError(): string | object { return this.error; } }