{"record":{"id":"b1e02662b53942e6","repo":"BerriAI/litellm","slug":"ollamaexception-original-exception","errorCode":null,"errorMessage":"OllamaException: {original_exception}","messagePattern":"OllamaException: (.+?)","errorType":"exception","errorClass":"ServiceUnavailableError","httpStatus":503,"severity":"error","filePath":"litellm/litellm_core_utils/exception_mapping_utils.py","lineNumber":1816,"sourceCode":"    custom_llm_provider: str,\n    error_str: str,\n    exception_type: str,\n    exception_provider: str,\n    extra_information: str,\n) -> None:\n    if isinstance(original_exception, dict):\n        error_str = original_exception.get(\"error\", \"\")\n    else:\n        error_str = str(original_exception)\n    if \"no such file or directory\" in error_str:\n        raise BadRequestError(\n            message=f\"OllamaException: Invalid Model/Model not loaded - {original_exception}\",\n            model=model,\n            llm_provider=\"ollama\",\n            response=getattr(original_exception, \"response\", None),\n        )\n    elif \"Failed to establish a new connection\" in error_str:\n        raise ServiceUnavailableError(\n            message=f\"OllamaException: {original_exception}\",\n            llm_provider=\"ollama\",\n            model=model,\n            response=getattr(original_exception, \"response\", None),\n        )\n    elif \"Invalid response object from API\" in error_str:\n        raise BadRequestError(\n            message=f\"OllamaException: {original_exception}\",\n            llm_provider=\"ollama\",\n            model=model,\n            response=getattr(original_exception, \"response\", None),\n        )\n    elif \"Read timed out\" in error_str:\n        raise Timeout(\n            message=f\"OllamaException: {original_exception}\",\n            llm_provider=\"ollama\",\n            model=model,\n        )","sourceCodeStart":1798,"sourceCodeEnd":1834,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/litellm_core_utils/exception_mapping_utils.py#L1798-L1834","documentation":"Ollama-specific catch-all: any Ollama error not matched by specific branches is re-raised as a normalized litellm exception with the original OllamaException text, keeping the local-server error visible to the caller.","triggerScenarios":"Thrown at litellm/litellm_core_utils/exception_mapping_utils.py:1816 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the Ollama server is running and reachable at the configured api_base.","Review the original Ollama exception for the specific cause."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}