@Override
    public void onRead(final Gson gson, final IOException ex) {
      StreamingOutput output = new StreamingOutput() {
        @Override
        public void write(OutputStream output) throws IOException, WebApplicationException {
          OutputStreamWriter writer = new OutputStreamWriter(output);
          gson.toJson(new JsonError(ex.getCause().getMessage()), writer);
          writer.flush();
        }
      };
      if (ex.getCause() instanceof RuntimeException) {
        throw new WebApplicationException(
            Response.status(Status.BAD_REQUEST)
                .type(MediaType.APPLICATION_JSON_TYPE)
                .entity(output)
                .build());
      }
    }
Handled media types
@return media types
gson/src/org/immutables/gson/stream/GsonMessageBodyProvider.java