mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 19:24:27 +00:00
(feat) improve error for testing slack
This commit is contained in:
parent
0b85061086
commit
ebaf2eef1f
1 changed files with 39 additions and 18 deletions
|
@ -6497,6 +6497,7 @@ async def health_services_endpoint(
|
||||||
|
|
||||||
Used by the UI to let user check if slack alerting is working as expected.
|
Used by the UI to let user check if slack alerting is working as expected.
|
||||||
"""
|
"""
|
||||||
|
try:
|
||||||
global general_settings, proxy_logging_obj
|
global general_settings, proxy_logging_obj
|
||||||
|
|
||||||
if service is None:
|
if service is None:
|
||||||
|
@ -6513,11 +6514,31 @@ async def health_services_endpoint(
|
||||||
)
|
)
|
||||||
|
|
||||||
if "slack" in general_settings.get("alerting", []):
|
if "slack" in general_settings.get("alerting", []):
|
||||||
await proxy_logging_obj.alerting_handler(message="This is a test", level="Low")
|
await proxy_logging_obj.alerting_handler(
|
||||||
|
message="This is a test", level="Low"
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=422,
|
status_code=422,
|
||||||
detail={"error": "No slack connection setup. Unable to test this."},
|
detail={
|
||||||
|
"error": '"slack" not in proxy config: general_settings. Unable to test this.'
|
||||||
|
},
|
||||||
|
)
|
||||||
|
except Exception as e:
|
||||||
|
if isinstance(e, HTTPException):
|
||||||
|
raise ProxyException(
|
||||||
|
message=getattr(e, "detail", f"Authentication Error({str(e)})"),
|
||||||
|
type="auth_error",
|
||||||
|
param=getattr(e, "param", "None"),
|
||||||
|
code=getattr(e, "status_code", status.HTTP_401_UNAUTHORIZED),
|
||||||
|
)
|
||||||
|
elif isinstance(e, ProxyException):
|
||||||
|
raise e
|
||||||
|
raise ProxyException(
|
||||||
|
message="Authentication Error, " + str(e),
|
||||||
|
type="auth_error",
|
||||||
|
param=getattr(e, "param", "None"),
|
||||||
|
code=status.HTTP_401_UNAUTHORIZED,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue