diff --git a/litellm/proxy/db/exception_handler.py b/litellm/proxy/db/exception_handler.py index e4c565e4464..59775d2dd73 100644 --- a/litellm/proxy/db/exception_handler.py +++ b/litellm/proxy/db/exception_handler.py @@ -195,6 +195,11 @@ class PrismaDBExceptionHandler: """ import asyncio + from prisma.errors import DataError + + if isinstance(e, DataError) and e.code == "P2037": + return True + if PrismaDBExceptionHandler.is_database_connection_error(e): return True if PrismaDBExceptionHandler.is_database_transport_error(e): diff --git a/tests/test_litellm/proxy/auth/test_auth_exception_handler.py b/tests/test_litellm/proxy/auth/test_auth_exception_handler.py index 11e6f483e35..2ab0a842b80 100644 --- a/tests/test_litellm/proxy/auth/test_auth_exception_handler.py +++ b/tests/test_litellm/proxy/auth/test_auth_exception_handler.py @@ -122,6 +122,15 @@ async def test_handle_authentication_error_data_layer_errors_do_not_fall_back( OSError("network is unreachable"), HTTPClientClosedError(), PrismaError("can't reach database server"), + DataError( + data={ + "user_facing_error": { + "error_code": "P2037", + "message": "Too many database connections opened: FATAL: sorry, too many clients already", + "meta": {"database_error": "FATAL: sorry, too many clients already"}, + } + } + ), RawQueryError( data={ "user_facing_error": {