コード例 #1
0
async def rve_error_handler(request: Request,
                            exc: RequestValidationError) -> ORJSONResponse:
    """Use JSEND protocol for validation errors."""
    return ORJSONResponse(status_code=422,
                          content={
                              "status": "failed",
                              "message": json.loads(exc.json())
                          })
コード例 #2
0
ファイル: main.py プロジェクト: kunansy/ReadingTracker
async def validation_exception_handler(request: Request,
                                       exc: RequestValidationError):
    logger.exception("Validation error occurred, %s", str(exc))

    context = {
        "request": request,
        "error": {
            "type": exc.__class__.__name__,
            "args": exc.args,
            "json": exc.json(indent=4)
        }
    }

    return templates.TemplateResponse("errors/500.html", context)
コード例 #3
0
ファイル: main.py プロジェクト: fossabot/gfw-data-api
async def rve_error_handler(request: Request, exc: RequestValidationError):
    return JSONResponse(
        status_code=422, content={"status": "failed", "message": json.loads(exc.json())}
    )