mirror of
https://github.com/open-webui/mcpo
synced 2025-06-26 18:26:58 +00:00
Print MCP exception stacktrace
This commit is contained in:
parent
27af7a6f22
commit
47888425e2
@ -1,4 +1,5 @@
|
||||
import json
|
||||
import traceback
|
||||
from typing import Any, Dict, ForwardRef, List, Optional, Type, Union
|
||||
|
||||
from fastapi import HTTPException
|
||||
@ -236,7 +237,9 @@ def get_tool_handler(
|
||||
return final_response
|
||||
|
||||
except McpError as e:
|
||||
print(f"MCP Error calling {endpoint_name}: {e.error}")
|
||||
print(
|
||||
f"MCP Error calling {endpoint_name}: {traceback.format_exc()}"
|
||||
)
|
||||
status_code = MCP_ERROR_TO_HTTP_STATUS.get(e.error.code, 500)
|
||||
raise HTTPException(
|
||||
status_code=status_code,
|
||||
@ -247,7 +250,9 @@ def get_tool_handler(
|
||||
),
|
||||
)
|
||||
except Exception as e:
|
||||
print(f"Unexpected error calling {endpoint_name}: {e}")
|
||||
print(
|
||||
f"Unexpected error calling {endpoint_name}: {traceback.format_exc()}"
|
||||
)
|
||||
raise HTTPException(
|
||||
status_code=500,
|
||||
detail={"message": "Unexpected error", "error": str(e)},
|
||||
@ -286,7 +291,9 @@ def get_tool_handler(
|
||||
return final_response
|
||||
|
||||
except McpError as e:
|
||||
print(f"MCP Error calling {endpoint_name}: {e.error}")
|
||||
print(
|
||||
f"MCP Error calling {endpoint_name}: {traceback.format_exc()}"
|
||||
)
|
||||
status_code = MCP_ERROR_TO_HTTP_STATUS.get(e.error.code, 500)
|
||||
# Propagate the error received from MCP as an HTTP exception
|
||||
raise HTTPException(
|
||||
@ -298,7 +305,9 @@ def get_tool_handler(
|
||||
),
|
||||
)
|
||||
except Exception as e:
|
||||
print(f"Unexpected error calling {endpoint_name}: {e}")
|
||||
print(
|
||||
f"Unexpected error calling {endpoint_name}: {traceback.format_exc()}"
|
||||
)
|
||||
raise HTTPException(
|
||||
status_code=500,
|
||||
detail={"message": "Unexpected error", "error": str(e)},
|
||||
|
||||
Loading…
Reference in New Issue
Block a user