INNER CODE UNIT · Python
handle_transcription_error
Kabanosk/whisper-website · src/exceptions.py:23
def handle_transcription_error(request: Request, exc: TranscriptionError) -> JSONResponse:
logger.error("Transcription request failed: {}", exc)
return JSONResponse(status_code=422, content={"detail": str(exc)})
@app.exception_handler(pydantic.ValidationError)
def handle_validation_error(request: Request, exc: pydantic.ValidationError) -> JSONResponse:
logger.error("Bad values in the form. {}", exc)
return JSONResponse(status_code=422, content={"detail": exc.errors()})