Skip to content
This repository was archived by the owner on Oct 7, 2020. It is now read-only.

Improve error message for badly-formatted json #166

Closed
glittershark opened this issue Jan 10, 2016 · 0 comments
Closed

Improve error message for badly-formatted json #166

glittershark opened this issue Jan 10, 2016 · 0 comments
Milestone

Comments

@glittershark
Copy link
Contributor

❯ echo '{"cmd":"base:commands","params":{"plugin": "hare"}}' | hie --one-shot | jq
{
  "error": {
    "msg": "FromJSONError \"failed to parse field params: empty\"",
    "code": "ParseError",
    "info": null
  }
}
glittershark added a commit to glittershark/haskell-ide-engine that referenced this issue Jan 10, 2016
Use Aeson's built-in `with<type>` functions, plus a custom error message
at the end of the ParamValP parser's Alternative chain to improve error
messages when parsing JSON requests.

Before:
-------

```
❯ echo '{"cmd":"base:commands","params":{"plugin": "hare"}}' | hie
--one-shot | jq
{
  "error": {
    "msg": "FromJSONError \"failed to parse field params: empty\"",
    "code": "ParseError",
    "info": null

  }

}
```

After:
------

```
❯ echo '{"cmd":"base:commands","params":{"plugin": "hare"}}' | stack exec -- hie --one-shot | jq
{
  "error": {
    "msg": "FromJSONError \"failed to parse field params: expected text, file, or position object, encountered String\"",
    "code": "ParseError",
    "info": null
  }
}
```

Closes haskell#166
@alanz alanz added this to the prehistory milestone Feb 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants