Open deffulsFHSS opened 7 months ago
I also encountered a Duplicate exception hander definition on: ...
exception recently. In my case, I had defined an error handler that attempts to handle the same error twice.
The code that caused the error was this:
from sanic import Sanic
from sanic import Request
from sanic.response import JSONResponse
from sanic.exceptions import BadRequest
from sanic.exceptions import InvalidUsage
from sanic.exceptions import HTTPException
app = Sanic(app_name, strict_slashes=False)
@app.exception(BadRequest, InvalidUsage)
async def handle_authentication_error(request: Request, exception: HTTPException) -> JSONResponse:
logger.exception(exception)
return response.json(
{
"description": "<some_description>",
"status": exception.status_code,
"reason": exception.message
},
status=exception.status_code
)
# rest of the code ...
here BadRequest
, and InvalidUsage
both points to the same exception definition BadRequest
. Got it fixed by removing InvalidUsage
, leaving only a single exception handler for a specific exception def.
However, I don't see any custom exception handling done in your code so not really sure what's the issue here.
This code gives me following Error. Looks like bug, i don't understand why.