I am implementing a JSON API using Phoenix, and one of the requirements is to return a custom JSON error message when a client sends malformed JSON. After looking at the docs for Phoenix and Plug, I still don’t know how to do this.
So when sending something like ‘{“hello”: "world}’ to the API, it should return something like ‘{“errcode”: “M_NOT_JSON”}’ with status code 400. Right now, it only logs the Plug.Parsers.ParseError and render HTML