Bug 1384943 - add initial implementation of SourceMapServiceWrapper; r=bgrins
authorTom Tromey <tom@tromey.com>
Mon, 31 Jul 2017 15:57:07 -0600
changeset 372716 8ecab1d291bf2edba0fb2175f5dccf72a9942e42
parent 372715 dbe9ba9aafde485e007d29bcb344b55c60b02e69
child 372717 24eaf9aca85c2bf6664ea92d295003f9c0be835b
push id47962
push userttromey@mozilla.com
push dateThu, 03 Aug 2017 19:57:21 +0000
treeherderautoland@8ecab1d291bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbgrins
bugs1384943
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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.