UNPKG

884 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.WsException = void 0;
4const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
5class WsException extends Error {
6 constructor(error) {
7 super();
8 this.error = error;
9 this.initMessage();
10 }
11 initMessage() {
12 if ((0, shared_utils_1.isString)(this.error)) {
13 this.message = this.error;
14 }
15 else if ((0, shared_utils_1.isObject)(this.error) &&
16 (0, shared_utils_1.isString)(this.error.message)) {
17 this.message = this.error.message;
18 }
19 else if (this.constructor) {
20 this.message = this.constructor.name
21 .match(/[A-Z][a-z]+|[0-9]+/g)
22 .join(' ');
23 }
24 }
25 getError() {
26 return this.error;
27 }
28}
29exports.WsException = WsException;