title: Return error with HttpEntity in Spring MVC
body: <p>I have this piece of code:</p>
  
  <pre><code> public HttpEntity&lt;byte[]&gt; getReport(){
          WebController.LOGGER.info("Requested report");
  
          try {
              byte[] reportData= reportService.getReport();
              return new HttpEntity&lt;byte[]&gt;(reportData);
          } catch (ReportGenerationException e) {
              //WHAT DO I RETURN HERE?
          }
      }
  </code></pre>
  
  <p>I want to return a 500 error when the report can not be generated, but HttpEntity does not allow me to set the HTTP status code. How can I work around this?</p>