Prevent Plug.ErrorHandler from re-raising error after callback

Thanks for the heads up regarding the empty map, I really should have seen that.
However, passing an empty string was merely an example of a use case. I should have changed the example to something more complex, like a malformed JSON:

"[{\"id\": 1}" 

In this example, the array is not closing, so it produces the following error:

  1. test PUT /cars returns 400 when the request has invalid JSON body (ApiTest)
    test/api_test.exs:157
    ** (Plug.Parsers.ParseError) malformed request, a Jason.DecodeError exception was raised with message “unexpected end of input at position 10”
    code: conn = Api.call(conn, @opts)
    stacktrace:
    (plug 1.10.4) lib/plug/parsers/json.ex:88: Plug.Parsers.JSON.decode/2
    (plug 1.10.4) lib/plug/parsers.ex:313: Plug.Parsers.reduce/8
    (api 0.1.0) lib/api.ex:1: Api.plug_builder_call/2
    (api 0.1.0) lib/plug/error_handler.ex:65: Api.call/2
    test/api_test.exs:168: (test)

Which makes sense, but the app still explodes.

After reading the tests, I don’t see how I can prevent it from exploding the app.
Receiving a malformed JSON is not an exception, is something that will happen somewhat regularly because of the nature of the clients.

I don’t want to blow up every time that happens, just to return a nice error message and move on.

As it stands, I really don’t understand what Plug.HandleErrors is useful for, if the app still blows up anyway.