Bug 1430022 - [WIP] Better error handling on copy command;r= draft
authorNicolas Chevobbe <nchevobbe@mozilla.com>
Mon, 15 Jan 2018 10:27:57 +0100
changeset 757271 d98ef59ea68e62b8f7c8c8f2e661e05a44a3b882
parent 757244 2c000486eac466da6623e4d7f7f1fd4e318f60e8
push id99732
push userbmo:nchevobbe@mozilla.com
push dateTue, 20 Feb 2018 15:14:09 +0000
bugs1430022
milestone60.0a1
Bug 1430022 - [WIP] Better error handling on copy command;r= MozReview-Commit-ID: GF3R4FM91CP
devtools/server/actors/webconsole/utils.js
--- a/devtools/server/actors/webconsole/utils.js
+++ b/devtools/server/actors/webconsole/utils.js
@@ -578,23 +578,26 @@ WebConsoleCommands._registerOriginal("co
   try {
     if (value instanceof Ci.nsIDOMElement) {
       payload = value.outerHTML;
     } else if (typeof value == "string") {
       payload = value;
     } else {
       payload = JSON.stringify(value, null, "  ");
     }
+    owner.helperResult = {
+      type: "copyValueToClipboard",
+      value: payload,
+    };
   } catch (ex) {
-    payload = "/* " + ex + " */";
+    owner.helperResult = {
+      type: "error",
+      message: ex.toString(),
+    };
   }
-  owner.helperResult = {
-    type: "copyValueToClipboard",
-    value: payload,
-  };
 });
 
 /**
  * (Internal only) Add the bindings to |owner.sandbox|.
  * This is intended to be used by the WebConsole actor only.
   *
   * @param object owner
   *        The owning object.