GramJs: Properly reject promise if result is unparsable
This commit is contained in:
parent
3d8bb54398
commit
cf2db92c61
@ -35,7 +35,6 @@ const { LogOut } = require('../tl').requests.auth;
|
||||
const { RPCMessageToError } = require('../errors');
|
||||
const { TypeNotFoundError } = require('../errors/Common');
|
||||
|
||||
|
||||
/**
|
||||
* MTProto Mobile Protocol sender
|
||||
* (https://core.telegram.org/mtproto/description)
|
||||
@ -82,7 +81,6 @@ class MTProtoSender {
|
||||
this._isMainSender = args.isMainSender;
|
||||
this._onConnectionBreak = args.onConnectionBreak;
|
||||
|
||||
|
||||
/**
|
||||
* whether we disconnected ourself or telegram did it.
|
||||
*/
|
||||
@ -557,9 +555,14 @@ class MTProtoSender {
|
||||
this._send_queue.append(new RequestState(new MsgsAck({ msgIds: [state.msgId] })));
|
||||
state.reject(error);
|
||||
} else {
|
||||
const reader = new BinaryReader(result.body);
|
||||
const read = state.request.readResult(reader);
|
||||
state.resolve(read);
|
||||
try {
|
||||
const reader = new BinaryReader(result.body);
|
||||
const read = state.request.readResult(reader);
|
||||
state.resolve(read);
|
||||
} catch (err) {
|
||||
state.reject(err);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user