Skip to content
This repository
Browse code

Fix for ajaxorg/cloud9infra#2886

  • Loading branch information...
commit 4b34aaf6401791609822b5252f060c0f0f6e7f76 1 parent b2ce7cd
authored October 31, 2012
26  plugins-client/ext.revisions/revisions_worker.js
@@ -166,14 +166,26 @@ self.onmessage = function(e) {
166 166
                     }
167 167
                 }
168 168
                 catch(err) {
169  
-                    self.postMessage({
  169
+                    return self.postMessage({
170 170
                         type: "newRevision.error",
171 171
                         path: e.data.path
172 172
                     });
173 173
                 }
174 174
             }
175 175
 
176  
-            patch = self.dmp.patch_make(beforeRevision, lastContent);
  176
+            try {
  177
+                patch = self.dmp.patch_make(beforeRevision, lastContent);
  178
+            }
  179
+            catch (e) {
  180
+                // Log the error. This is probably an instance of `Unknown call
  181
+                // format to patch_make`. Passing types of `beforeRevision` and
  182
+                // `lastContent` because it is likely that any of those is null.
  183
+                debug(e, typeof beforeRevision, typeof lastContent);
  184
+                return self.postMessage({
  185
+                    type: "newRevision.error",
  186
+                    path: e.data.path
  187
+                });
  188
+            }
177 189
             docContentsOnRev[e.data.path] = lastContent;
178 190
 
179 191
             // If there is no actual changes, let's return
@@ -201,7 +213,15 @@ self.onmessage = function(e) {
201 213
         case "recovery":
202 214
             var currentContent = e.data.lastContent;
203 215
             var realContent = e.data.realContent;
204  
-            patch = self.dmp.patch_make(currentContent, realContent);
  216
+            try {
  217
+                patch = self.dmp.patch_make(currentContent, realContent);
  218
+            }
  219
+            catch (e) {
  220
+                // Log the error. This is probably an instance of `Unknown call
  221
+                // format to patch_make`. Passing types of `beforeRevision` and
  222
+                // `lastContent` because it is likely that any of those is null.
  223
+                return debug(e, typeof currentContent, typeof realContent);
  224
+            }
205 225
 
206 226
             // If there is no actual changes, let's return
207 227
             if (patch.length === 0) {

0 notes on commit 4b34aaf

Please sign in to comment.
Something went wrong with that request. Please try again.