Browse Source

Improved mtproto errors handling

master
Igor Zhukov 10 years ago
parent
commit
06601f50d5
  1. 17
      app/js/lib/mtproto.js
  2. 2
      app/partials/error_modal.html

17
app/js/lib/mtproto.js

@ -967,10 +967,12 @@ TLDeserialization.prototype.fetchObject = function (type, field) {
predicate = constructorData.predicate; predicate = constructorData.predicate;
var result = {'_': predicate}, var result = {'_': predicate},
overrideKey = (this.mtproto ? 'mt_' : '') + predicate,
self = this; self = this;
if (this.override[predicate]) {
this.override[predicate].apply(this, [result, field + '[' + predicate + ']']); if (this.override[overrideKey]) {
this.override[overrideKey].apply(this, [result, field + '[' + predicate + ']']);
} else { } else {
angular.forEach(constructorData.params, function (param) { angular.forEach(constructorData.params, function (param) {
result[param.name] = self.fetchObject(param.type, field + '[' + predicate + '][' + param.name + ']'); result[param.name] = self.fetchObject(param.type, field + '[' + predicate + '][' + param.name + ']');
@ -2227,7 +2229,7 @@ factory('MtpNetworkerFactory', function (MtpDcConfigurator, MtpMessageIdGenerato
var deserializerOptions = { var deserializerOptions = {
mtproto: true, mtproto: true,
override: { override: {
message: function (result, field) { mt_message: function (result, field) {
result.msg_id = this.fetchLong(field + '[msg_id]'); result.msg_id = this.fetchLong(field + '[msg_id]');
result.seqno = this.fetchInt(field + '[seqno]'); result.seqno = this.fetchInt(field + '[seqno]');
result.bytes = this.fetchInt(field + '[bytes]'); result.bytes = this.fetchInt(field + '[bytes]');
@ -2237,12 +2239,17 @@ factory('MtpNetworkerFactory', function (MtpDcConfigurator, MtpMessageIdGenerato
try { try {
result.body = this.fetchObject('Object', field + '[body]'); result.body = this.fetchObject('Object', field + '[body]');
} catch (e) { } catch (e) {
console.error(dT(), 'parse error', e.message, e.stack);
result.body = {_: 'parse_error', error: e}; result.body = {_: 'parse_error', error: e};
} }
this.offset = offset + result.bytes; if (this.offset != offset + result.bytes) {
console.warn(dT(), 'set offset', this.offset, offset, result.bytes);
console.log(dT(), result);
this.offset = offset + result.bytes;
}
// console.log(dT(), 'override message', result); // console.log(dT(), 'override message', result);
}, },
rpc_result: function (result, field) { mt_rpc_result: function (result, field) {
result.req_msg_id = this.fetchLong(field + '[req_msg_id]'); result.req_msg_id = this.fetchLong(field + '[req_msg_id]');
var sentMessage = self.sentMessages[result.req_msg_id], var sentMessage = self.sentMessages[result.req_msg_id],

2
app/partials/error_modal.html

@ -57,7 +57,7 @@
<div ng-if="error" class="error_modal_details" ng-switch="error.detailsShown"> <div ng-if="error" class="error_modal_details" ng-switch="error.detailsShown">
<textarea ng-switch-when="true" rows="3" onclick="this.select()">Method: {{error.input || 'N/A'}} <textarea ng-switch-when="true" rows="3" onclick="this.select()">Method: {{error.input || 'N/A'}}
Result: {{error.originalError || error}} Result: {{error.originalError ? error.originalError : (error.stack ? (error.name || '') + ' ' + (error.description || error.message) : error)}}
Stack: {{error.stack}}</textarea> Stack: {{error.stack}}</textarea>
<div ng-switch-default> <div ng-switch-default>
<a href="" ng-click="error.detailsShown = true">Technical details here</a> <a href="" ng-click="error.detailsShown = true">Technical details here</a>

Loading…
Cancel
Save