diff --git a/remote/.eslintrc.js b/remote/.eslintrc.js index 1ba4a03c8ee0..f386a7357602 100644 --- a/remote/.eslintrc.js +++ b/remote/.eslintrc.js @@ -3,5 +3,6 @@ module.exports = { "rules": { "max-len": "off", + "no-tabs": "off", } }; diff --git a/remote/Error.jsm b/remote/Error.jsm index abd832627a46..77b41ed66d12 100644 --- a/remote/Error.jsm +++ b/remote/Error.jsm @@ -71,18 +71,25 @@ class UnsupportedError extends RemoteAgentError {} class UnknownMethodError extends RemoteAgentError {} function formatError(error, {stack = false} = {}) { - const ls = []; + const els = []; - ls.push(`${error.name}: ${error.message ? `${error.message}:` : ""}`); + els.push(error.name); + if (error.message) { + els.push(": "); + els.push(error.message); + } if (stack && error.stack) { + els.push(":\n"); + const stack = error.stack.trim().split("\n"); - ls.push(stack.map(line => `\t${line}`).join("\n")); + els.push(stack.map(line => `\t${line}`).join("\n")); if (error.cause) { - ls.push("caused by: " + formatError(error.cause, {stack})); + els.push("\n"); + els.push("caused by: " + formatError(error.cause, {stack})); } } - return ls.join("\n"); + return els.join(""); } diff --git a/remote/test/unit/test_Error.js b/remote/test/unit/test_Error.js index 279a579e0f33..e5d760969761 100644 --- a/remote/test/unit/test_Error.js +++ b/remote/test/unit/test_Error.js @@ -46,15 +46,15 @@ add_test(function test_RemoteAgentError_toString() { add_test(function test_RemoteAgentError_format() { const {format} = RemoteAgentError; - equal(format({name: "HippoError"}), "HippoError: "); - equal(format({name: "HorseError", message: "neigh"}), "HorseError: neigh:"); + equal(format({name: "HippoError"}), "HippoError"); + equal(format({name: "HorseError", message: "neigh"}), "HorseError: neigh"); const dog = { name: "DogError", message: "woof", stack: " one\ntwo\nthree ", }; - equal(format(dog), "DogError: woof:"); + equal(format(dog), "DogError: woof"); equal(format(dog, {stack: true}), `DogError: woof: one @@ -67,7 +67,7 @@ add_test(function test_RemoteAgentError_format() { stack: "four\nfive\nsix", cause: dog, }; - equal(format(cat), "CatError: meow:"); + equal(format(cat), "CatError: meow"); equal(format(cat, {stack: true}), `CatError: meow: four