# Possible to add better PPX error messages

**URL:** <https://discuss.ocaml.org/t/possible-to-add-better-ppx-error-messages/1894>\
**Category:** Learning\
**Created:** [April 22, 2018, 10:08pm UTC](https://discuss.ocaml.org/t/possible-to-add-better-ppx-error-messages/1894 "2018-04-22T22:08:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ncthbrt](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/ncthbrt/32/745_2.png) [@ncthbrt](https://discuss.ocaml.org/u/ncthbrt)\
**Post date:** [April 22, 2018, 10:08pm UTC](https://discuss.ocaml.org/t/possible-to-add-better-ppx-error-messages/1894/1 "2018-04-22T22:08:31Z")

</div>

Hi there. I’m writing a ppx for a library I’m working on. The ppx parses a string, and I’d like to offer an explanation as to why parsing fails from within editors like vscode. Is this at all possible? For reference, this is the repository I’m working on: [http://github.com/ncthbrt/reconstruct](http://github.com/ncthbrt/reconstruct)

Thank you

---

<div class="post-metadata">

**Author:** ![Drup](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/drup/32/35_2.png) [@Drup](https://discuss.ocaml.org/u/Drup)\
**Post date:** [April 22, 2018, 10:29pm UTC](https://discuss.ocaml.org/t/possible-to-add-better-ppx-error-messages/1894/2 "2018-04-22T22:29:34Z")

</div>

Since vscode uses merlin (afaik), just return normal error messages (either by inserting error nodes in the AST or by using `Location.raise_errorf`). merlin will report them, so you don’t need to duplicate your work for errors reported by editors or compiler.

The really important part is to give very good _locations_ to your error messages.

---

<div class="post-metadata">

**Author:** ![ncthbrt](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/ncthbrt/32/745_2.png) [@ncthbrt](https://discuss.ocaml.org/u/ncthbrt)\
**Post date:** [April 23, 2018, 10:18am UTC](https://discuss.ocaml.org/t/possible-to-add-better-ppx-error-messages/1894/3 "2018-04-23T10:18:54Z")

</div>

Oh. I didn’t know about error nodes. Thanks @Drup 🙂
