title: Custom JSON errors for Servant-server
body: <p>When using <a href="https://haskell-servant.readthedocs.io/en/stable/" rel="noreferrer">servant</a>, I'd like to return all errors as JSON. Currently, if a request fails to parse, I see an error message like this, returned as plain text</p>
  
  <pre><code>Failed reading: not a valid json value
  </code></pre>
  
  <p>Instead I would like to return this as <code>application/json</code></p>
  
  <pre><code>{"error":"Failed reading: not a valid json value"}
  </code></pre>
  
  <p>How can I do this? The docs say <code>ServantErr</code> is the default error type, and I can certainly respond with custom errors inside my handlers, but if parsing fails I don't see how I can return a custom error. </p>