Bug 1525966 - Support string errors when detach fails in target fronts draft
authorJulian Descottes <jdescottes@mozilla.com>
Wed, 04 Dec 2019 16:51:10 +0000
changeset 2516018 952020252e97a8b4ab07ebdeb92f80607613932f
parent 2516017 f2254279690202817fe48e0cbd285970e532c179
child 2516019 3c45aea5d07b5f875340be54f35af628b2c07e5b
push id460091
push userreviewbot
push dateWed, 04 Dec 2019 16:51:41 +0000
treeherdertry@3c45aea5d07b [default view] [failures only]
bugs1525966
milestone73.0a1
Bug 1525966 - Support string errors when detach fails in target fronts Differential Diff: PHID-DIFF-5oeznp63wlxwhh7kj6vi
devtools/shared/fronts/targets/browsing-context.js
devtools/shared/fronts/targets/target-mixin.js
devtools/shared/fronts/targets/worker.js
--- a/devtools/shared/fronts/targets/browsing-context.js
+++ b/devtools/shared/fronts/targets/browsing-context.js
@@ -132,18 +132,19 @@ class BrowsingContextTargetFront extends
     return this.client.mainRoot.listRemoteFrames(this.browsingContextID);
   }
 
   async detach() {
     let response;
     try {
       response = await super.detach();
     } catch (e) {
+      const errorMessage = typeof e === "string" ? e : e.message;
       console.warn(
-        `Error while detaching the browsing context target front: ${e.message}`
+        `Error while detaching the browsing context target front: ${errorMessage}`
       );
     }
 
     // Remove listeners set in attach
     this.off("tabNavigated", this._onTabNavigated);
     this.off("frameUpdate", this._onFrameUpdate);
 
     return response;
--- a/devtools/shared/fronts/targets/target-mixin.js
+++ b/devtools/shared/fronts/targets/target-mixin.js
@@ -462,17 +462,18 @@ function TargetMixin(parentClass) {
         } else if (this.detach && this.actorID) {
           // The client was handed to us, so we are not responsible for closing
           // it. We just need to detach from the tab, if already attached.
           // |detach| may fail if the connection is already dead, so proceed with
           // cleanup directly after this.
           try {
             await this.detach();
           } catch (e) {
-            console.warn(`Error while detaching target: ${e.message}`);
+            const errorMessage = typeof e === "string" ? e : e.message;
+            console.warn(`Error while detaching target: ${errorMessage}`);
           }
         }
 
         // Do that very last in order to let a chance to dispatch `detach` requests.
         super.destroy();
 
         this._cleanup();
       })();
--- a/devtools/shared/fronts/targets/worker.js
+++ b/devtools/shared/fronts/targets/worker.js
@@ -82,18 +82,19 @@ class WorkerTargetFront extends TargetMi
     return this._attach;
   }
 
   async detach() {
     let response;
     try {
       response = await super.detach();
     } catch (e) {
+      const errorMessage = typeof e === "string" ? e : e.message;
       console.warn(
-        `Error while detaching the worker target front: ${e.message}`
+        `Error while detaching the worker target front: ${errorMessage}`
       );
     }
 
     if (this.registration) {
       await this.registration.allowShutdown();
       this.registration = null;
     }