code: public static FailedRequest getFailedRequest(int httpStatus, String contentType, InputStream content) {
      FailedRequest failure = null;
  
      // by default XML is supported
      if ( contentType != null ) {
        MediaType mediaType = MediaType.parse(contentType);
        if ( "xml".equals(mediaType.subtype()) ) {
          FailedRequestParser xmlParser = new FailedRequestXMLParser();
  
          failure = xmlParser.parseFailedRequest(httpStatus, content);
        } else if ( "json".equals(mediaType.subtype()) ) {
          failure = jsonFailedRequest(httpStatus, content);
        }
      } else if (httpStatus == 404) {
        failure = new FailedRequest();
        failure.setStatusCode(httpStatus);
        failure.setMessageString("");
        failure.setStatusString("Not Found");
      }
      if ( failure == null ) {
        failure = new FailedRequest();
        failure.setStatusCode(httpStatus);
        failure.setMessageCode("UNKNOWN");
        failure.setMessageString("Server (not a REST instance?) did not respond with an expected REST Error message.");
        failure.setStatusString("UNKNOWN");
      }
      if (failure.getStatusCode() == 401) {
        failure.setMessageString("Unauthorized");
        failure.setStatusString("Failed Auth");
      }
      return failure;
  
    }
docs: /*
  send an InputStream to this handler in order to create an error block.