title: Overriding fastAPI's HTTPException response body
body: <p>I'm currently writing a few end points for an API in fastAPI.
  I'm defining classes that extend fastapi's HTTPException.</p>
  <p>The problem is that HTTPException returns a response body with an attribute called detail which will either be a string or a json structure depending on what object you pass to it as seem below.</p>
  <pre><code>{
    &quot;detail&quot;: {
      &quot;msg&quot;: &quot;error message here&quot;
    }
  }
  
  
  {   &quot;detail&quot;: &quot;error message here&quot; }
  </code></pre>
  <p>I would like to override this behavior and let it respond with my own structure.</p>
  <p>I'm aware that i can install custom exceptions using the exception handler decorator and have that return a JSONResponse object but this is not what i'm looking for.</p>