diff --git a/litellm/proxy/guardrails/guardrail_hooks/custom_code/custom_code_guardrail.py b/litellm/proxy/guardrails/guardrail_hooks/custom_code/custom_code_guardrail.py index 58502e309ef..afdd3630a55 100644 --- a/litellm/proxy/guardrails/guardrail_hooks/custom_code/custom_code_guardrail.py +++ b/litellm/proxy/guardrails/guardrail_hooks/custom_code/custom_code_guardrail.py @@ -257,11 +257,11 @@ class CustomCodeGuardrail(CustomGuardrail): verbose_proxy_logger.error( f"Custom code guardrail '{self.guardrail_name}' execution error: {e}" ) - raise CustomCodeExecutionError( - f"Custom code guardrail execution failed: {e}", - details={ - "guardrail_name": self.guardrail_name, - "input_type": input_type, + raise HTTPException( + status_code=400, + detail={ + "error": f"Custom code guardrail execution failed: {e}", + "guardrail": self.guardrail_name, }, ) from e