I'm currently writing a few end points for an API in fastAPI. I'm defining classes that extend fastapi's HTTPException.
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.
{
"detail": {
"msg": "error message here"
}
}
{ "detail": "error message here" }
I would like to override this behavior and let it respond with my own structure.
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.