File size: 780 Bytes
ea7575f
193db9d
ea7575f
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
from shared.workflows.errors import ProviderAPIError, WorkflowExecutionError


def create_error_message(e: Exception) -> str:
    """Create an error message for a given exception."""
    if isinstance(e, ProviderAPIError):
        return f"Our {e.provider} models are currently experiencing issues. Please try again later. \n\nIf the problem persists, please contact support."
    elif isinstance(e, WorkflowExecutionError):
        return f"Workflow execution failed: {e}. Please try again later. \n\nIf the problem persists, please contact support."
    elif isinstance(e, ValueError):
        return f"Invalid input -- {e}. Please try again. \n\nIf the problem persists, please contact support."
    else:
        return "An unexpected error occurred. Please contact support."