UNPKG

@nestjs/websockets

Version:

Nest - modern, fast, powerful node.js web framework (@websockets)

27 lines (26 loc) 693 B
import { isObject, isString } from '@nestjs/common/internal'; export class WsException extends Error { error; constructor(error) { super(); this.error = error; this.initMessage(); } initMessage() { if (isString(this.error)) { this.message = this.error; } else if (isObject(this.error) && isString(this.error.message)) { this.message = this.error.message; } else if (this.constructor) { this.message = this.constructor.name .match(/[A-Z][a-z]+|[0-9]+/g) .join(' '); } } getError() { return this.error; } }