mirror of
https://github.com/Maks1mS/nestjs-telegraf.git
synced 2024-12-24 15:04:38 +03:00
chore(telegraf-exception): remove message parsing
This commit is contained in:
parent
6656c39bd9
commit
daf0d8ffdf
@ -1,24 +1 @@
|
|||||||
import { isObject, isString } from '@nestjs/common/utils/shared.utils';
|
export class TelegrafException extends Error {}
|
||||||
|
|
||||||
export class TelegrafException extends Error {
|
|
||||||
constructor(private readonly error: string | object) {
|
|
||||||
super();
|
|
||||||
this.initMessage();
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Check real error format
|
|
||||||
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(' ');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user