Spaces:
Sleeping
Sleeping
from fastapi.responses import JSONResponse | |
def handle_exception(e: Exception): | |
"""Helper function to handle exceptions in a consistent way.""" | |
return JSONResponse( | |
status_code=500, content=f"An unexpected error occurred: {str(e)}" | |
) | |
def handle_error(e, message): | |
return JSONResponse(status_code=500, content={"error occurs": f"{message}: {str(e)}"}) | |
def not_found_error(message): | |
return JSONResponse(status_code=404, content={"not found message": message}) | |
def no_entries_found(message): | |
return JSONResponse(status_code=404, content={"no entries found": message}) | |