From f39897514021dcd9812d548f385112223a55e57c Mon Sep 17 00:00:00 2001 From: Kolja Lampe Date: Tue, 28 Aug 2018 22:58:57 +0200 Subject: [PATCH 1/2] Add errors with explanation for the removed options warn and pathToMake --- index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/index.js b/index.js index 94d395d..b635c4c 100644 --- a/index.js +++ b/index.js @@ -186,6 +186,10 @@ function compilerArgsFromOptions(options) { if (supportedOptions.indexOf(opt) === -1) { if (opt === "yes") { throw new Error('node-elm-compiler received the `yes` option, but that was removed in Elm 0.19. Try re-running without passing the `yes` option.'); + } else if (opt === "warn") { + throw new Error('node-elm-compiler received the `warn` option, but that was removed in Elm 0.19. Try re-running without passing the `warn` option.'); + } else if (opt === "pathToMake") { + throw new Error('node-elm-compiler received the `pathToMake` option, but that was renamed to `pathToElm` in Elm 0.19. Try re-running after renaming the parameter to `pathToElm`.'); } else { throw new Error('node-elm-compiler was given an unrecognized Elm compiler option: ' + opt); } From 46008dd11c00c24f2ede60a593454ca1fece5f02 Mon Sep 17 00:00:00 2001 From: Kolja Lampe Date: Tue, 28 Aug 2018 23:12:30 +0200 Subject: [PATCH 2/2] Print error message for errors without error codes and cleanup error stings --- index.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index b635c4c..4de804c 100644 --- a/index.js +++ b/index.js @@ -67,16 +67,18 @@ function compilerErrorToString(err, pathToElm) { if ((typeof err === "object") && (typeof err.code === "string")) { switch (err.code) { case "ENOENT": - return ("Could not find Elm compiler \"" + pathToElm + "\". Is it installed?") + return "Could not find Elm compiler \"" + pathToElm + "\". Is it installed?"; case "EACCES": - return ("Elm compiler \"" + pathToElm + "\" did not have permission to run. Do you need to give it executable permissions?"); + return "Elm compiler \"" + pathToElm + "\" did not have permission to run. Do you need to give it executable permissions?"; default: - return ("Error attempting to run Elm compiler \"" + pathToElm + "\":\n" + err); + return "Error attempting to run Elm compiler \"" + pathToElm + "\":\n" + err; } + } else if ((typeof err === "object") && (typeof err.message === "string")) { + return JSON.stringify(err.message); } else { - return ("Exception thrown when attempting to run Elm compiler " + JSON.stringify(pathToElm) + ":\n"); + return "Exception thrown when attempting to run Elm compiler " + JSON.stringify(pathToElm); } }