Bug 1384943 - add initial implementation of SourceMapServiceWrapper; r?bgrins draft
authorTom Tromey <tom@tromey.com>
Mon, 31 Jul 2017 15:57:07 -0600
changeset 620535 16864557ef4734aa47205fd9a3b454e230d4d60a
parent 619751 575b97604258213812675e2a93ced49e33e8c7b2
child 640727 1acd25673d5fcdbe87c75bf67a1076ec9484b3ba
push id72070
push userbmo:ttromey@mozilla.com
push dateThu, 03 Aug 2017 14:52:07 +0000
reviewersbgrins
bugs1384943
milestone56.0a1
Bug 1384943 - add initial implementation of SourceMapServiceWrapper; r?bgrins This adds a simple wrapper for the source map service. This wrapper logs errors using console.error, preserving the status quo from before this series. MozReview-Commit-ID: 2ckUZaerrcJ
devtools/client/framework/toolbox.js
--- a/devtools/client/framework/toolbox.js
+++ b/devtools/client/framework/toolbox.js
@@ -539,18 +539,30 @@ Toolbox.prototype = {
   /**
    * Unconditionally create and get the source map service.
    */
   _createSourceMapService: function () {
     if (this._sourceMapService) {
       return this._sourceMapService;
     }
     // Uses browser loader to access the `Worker` global.
-    this._sourceMapService =
-      this.browserRequire("devtools/client/shared/source-map/index");
+    let service = this.browserRequire("devtools/client/shared/source-map/index");
+
+    // Provide a wrapper for the service that reports errors more nicely.
+    this._sourceMapService = new Proxy(service, {
+      get: (target, name) => {
+        if (name === "getOriginalURLs") {
+          return (urlInfo) => {
+            return target.getOriginalURLs(urlInfo).catch(console.error);
+          };
+        }
+        return target[name];
+      },
+    });
+
     this._sourceMapService.startSourceMapWorker(SOURCE_MAP_WORKER);
     return this._sourceMapService;
   },
 
   /**
    * A common access point for the client-side mapping service for source maps that
    * any panel can use.  This is a "low-level" API that connects to
    * the source map worker.