|
@@ -277,7 +277,9 @@ export class MTProtoSender {
|
|
|
this._log.error(
|
|
|
`WebSocket connection failed attempt: ${attempt + 1}`
|
|
|
);
|
|
|
- if (this._log.canSend(LogLevel.ERROR)) {
|
|
|
+ if (this._client._errorHandler) {
|
|
|
+ await this._client._errorHandler(err as Error);
|
|
|
+ } if (this._log.canSend(LogLevel.ERROR)) {
|
|
|
console.error(err);
|
|
|
}
|
|
|
await sleep(this._delay);
|
|
@@ -579,7 +581,9 @@ export class MTProtoSender {
|
|
|
return;
|
|
|
} else {
|
|
|
this._log.error("Unhandled error while receiving data");
|
|
|
- if (this._log.canSend(LogLevel.ERROR)) {
|
|
|
+ if (this._client._errorHandler) {
|
|
|
+ await this._client._errorHandler(e as Error);
|
|
|
+ } if (this._log.canSend(LogLevel.ERROR)) {
|
|
|
console.log(e);
|
|
|
}
|
|
|
this.reconnect();
|
|
@@ -601,7 +605,9 @@ export class MTProtoSender {
|
|
|
}
|
|
|
} else {
|
|
|
this._log.error("Unhandled error while receiving data");
|
|
|
- if (this._log.canSend(LogLevel.ERROR)) {
|
|
|
+ if (this._client._errorHandler) {
|
|
|
+ await this._client._errorHandler(e as Error);
|
|
|
+ } if (this._log.canSend(LogLevel.ERROR)) {
|
|
|
console.log(e);
|
|
|
}
|
|
|
}
|
|
@@ -978,7 +984,9 @@ export class MTProtoSender {
|
|
|
await this._disconnect();
|
|
|
} catch (err) {
|
|
|
this._log.warn("Error happened while disconnecting");
|
|
|
- if (this._log.canSend(LogLevel.ERROR)) {
|
|
|
+ if (this._client._errorHandler) {
|
|
|
+ await this._client._errorHandler(err as Error);
|
|
|
+ } if (this._log.canSend(LogLevel.ERROR)) {
|
|
|
console.error(err);
|
|
|
}
|
|
|
}
|