Skip to content

Make errors from compile() nicer #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

shuhei
Copy link

@shuhei shuhei commented Sep 8, 2018

Making errors from compile() nicer. I couldn't add a unit test for this because the error is thrown asynchronously and hard to catch.

Also updating the version in package-lock.json.

Before & After

With the following test script:

const compiler = require('.');

var opts = {
  pathToElm: "i-dont-exist",
  verbose: true,
  cwd: '',
};

compiler.compile("Parent.elm", opts);

Before:

[~/work/elm/node-elm-compiler] (master *) € node test.js
Running i-dont-exist make Parent.elm
/Users/shuhei/work/elm/node-elm-compiler/index.js:103
      .on('error', function(err) { throw (err); });
                                   ^

Error: spawn i-dont-exist ENOENT
    at _errnoException (util.js:992:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19)
    at onErrorNT (internal/child_process.js:372:16)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)
    at Function.Module.runMain (module.js:695:11)
    at startup (bootstrap_node.js:191:16)
    at bootstrap_node.js:612:3

After:

[~/work/elm/node-elm-compiler] (master *) € node test.js
Running i-dont-exist make Parent.elm

/Users/shuhei/work/elm/node-elm-compiler/index.js:103
      .on('error', function(err) { throw compilerErrorToString(err); });
                                   ^
Could not find Elm compiler "undefined". Is it installed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant