Commit ab6a15537cbe96ca1571bf39b323f3b2a36a68d9

Authored by Adhidarma Hadiwinoto
1 parent 46b37b2432
Exists in master

tambah try catch saat update resource

Showing 1 changed file with 13 additions and 6 deletions Side-by-side Diff

... ... @@ -41,18 +41,25 @@ MatrixUtil.prototype.updateBuddyState = function(jid, state, statusText, resourc
41 41 matrix.buddies[jid] = {resources: {}};
42 42 }
43 43  
44   - matrix.buddies[jid]['resources'][resource] = {
45   - state: state,
46   - statusText: statusText,
47   - lastUpdate: moment().format('YYYY-MM-DD HH:mm:ss')
  44 + try {
  45 + matrix.buddies[jid]['resources'][resource] = {
  46 + state: state,
  47 + statusText: statusText,
  48 + lastUpdate: moment().format('YYYY-MM-DD HH:mm:ss')
  49 + }
48 50 }
  51 + catch(e) {
  52 + logger.warn('MatrixUtil: Exception on update resources on matrix', {jid: jid, state: state, statusText: statusText, resource: resource});
  53 + }
  54 +
  55 +
49 56  
50 57 if (resource != 'undefined' && matrix.buddies[jid].resources['undefined']) {
51 58 try {
52 59 delete matrix.buddies[jid].resources['undefined'];
53 60 }
54 61 catch(e) {};
55   - }
  62 + }
56 63 }
57 64  
58 65 MatrixUtil.prototype.isAFriend = function(jid) {
... ... @@ -110,7 +117,7 @@ MatrixUtil.prototype.updateLastIncoming = function(sender, msg) {
110 117  
111 118 MatrixUtil.prototype.updateLastOutgoing = function(destination, msg) {
112 119 var matrix = this.matrix;
113   -
  120 +
114 121 if (!matrix) {
115 122 return;
116 123 }