From aa533cc06149ae6f0a3f560b4f6964d1b6c09f22 Mon Sep 17 00:00:00 2001 From: nealshail Date: Mon, 7 Aug 2017 16:00:34 +0100 Subject: [PATCH] JSON.stringify(Error()) always printing {} MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit By default JSON.stringify(new Error(‘some error message’)) will always print {}. need to specifiy which properties of the error message to print out. see https://stackoverflow.com/questions/18391212/is-it-not-possible-to-stringify-an-error-using-json-stringify --- utils/invoke_task.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/invoke_task.js b/utils/invoke_task.js index a9db0b9..7836584 100644 --- a/utils/invoke_task.js +++ b/utils/invoke_task.js @@ -87,7 +87,7 @@ invokeTask.getHandler = function (grunt) { grunt.log.writeln(""); grunt.log.writeln("Failure! Message:"); grunt.log.writeln("------------------"); - var msg = (typeof(error) === 'object') ? JSON.stringify(error) : error; + var msg = (typeof(error) === 'object') ? JSON.stringify(error, ["message", "arguments", "type", "name"]) : error; grunt.log.writeln((typeof(error) !== 'undefined') ? msg : "Error not provided."); done(false); },