Skip to content
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

Improve config file parsing error messages #269

Closed
3 tasks done
borsboom opened this issue Jun 11, 2015 · 7 comments
Closed
3 tasks done

Improve config file parsing error messages #269

borsboom opened this issue Jun 11, 2015 · 7 comments

Comments

@borsboom
Copy link
Contributor

For example, if I put install-ghc: 123 in a stack.yaml, I get this not very informative error:

$ stack exec true
AesonException "when expecting a Bool, encountered Number instead"

We should at least catch AesonExceptions when parsing the config files and wrap them in our own "ConfigParseFailedException" (or something like that), and include the path to the config file where the failure occurred in the message. If there was a way to get Aeson to report the field with the error that would be even better (I don't know if that's possible though).

  • Include field with error in AesonException.
  • Include config file path in error message.
  • Include link to config documentation in error message.
@snoyberg
Copy link
Contributor

I agree. This is also related to #48.

@snoyberg snoyberg added this to the First stable release (0.1.0.0?) milestone Jun 11, 2015
@chrisdone
Copy link
Member

@snoyberg
Copy link
Contributor

No objection from me.

@radix
Copy link
Contributor

radix commented Jun 11, 2015

I commented about some stuff with config file parsing in #211, but this ticket is more clearly more appropriate for my suggestion, so I'll just restate it here:

There's now a wiki page (still in progress) documenting everything about stack.yaml here: https://github.com/commercialhaskell/stack/wiki/stack.yaml

I recommend that all config-file parsing errors show a link to this page, and if possible, a specific subsection about whatever directive couldn't be parsed.

@gregwebs
Copy link
Contributor

The way I have tackled this in the past is to just override the .: etc operators to give they key in the failure message. I do this where Aeson is imported into the project (Import.Aeson or Aeson.Extended or whatever your preferred approach is there). The link to the wiki can probably be added by using modifyFailure. I would suggest first seeing how much this approach improves the situation before using a new parsing library.

gregwebs added a commit that referenced this issue Jun 11, 2015
This overrides the aeson combinators to have better error messages
Just import Data.Aeson.Extended instead of Data.Aeson
@gregwebs
Copy link
Contributor

Addressed by #284. Here is the output I get from that.

AesonException "failed to parse field install-ghc: when expecting a Bool, encountered Number instead"

Including both the path to the config file and a link to the wiki documentation of the YAML config should be done, but perhaps a separate issue can be opened for that?

gregwebs added a commit that referenced this issue Jun 12, 2015
This overrides the aeson combinators to have better error messages
Just import Data.Aeson.Extended instead of Data.Aeson
@borsboom
Copy link
Contributor Author

Probably can leave this issue open to address the rest (I've added steps to the top comment), but I have no objection to merging the pull request. Thanks!

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

No branches or pull requests

5 participants