mirror of
https://github.com/langgenius/dify.git
synced 2026-05-24 19:07:53 +08:00
fix(errors): clean unnecessary | None in error classes (#36135)
This commit is contained in:
@ -1,3 +1,3 @@
|
||||
class BaseServiceError(ValueError):
|
||||
def __init__(self, description: str | None = None):
|
||||
def __init__(self, description: str = ""):
|
||||
self.description = description
|
||||
|
||||
@ -6,7 +6,7 @@ from services.errors.base import BaseServiceError
|
||||
class EnterpriseServiceError(BaseServiceError):
|
||||
"""Base exception for enterprise service errors."""
|
||||
|
||||
def __init__(self, description: str | None = None, status_code: int | None = None):
|
||||
def __init__(self, description: str = "", status_code: int | None = None):
|
||||
super().__init__(description)
|
||||
self.status_code = status_code
|
||||
|
||||
@ -20,26 +20,26 @@ class EnterpriseAPIError(EnterpriseServiceError):
|
||||
class EnterpriseAPINotFoundError(EnterpriseServiceError):
|
||||
"""Enterprise API returned 404 Not Found."""
|
||||
|
||||
def __init__(self, description: str | None = None):
|
||||
def __init__(self, description: str = ""):
|
||||
super().__init__(description, status_code=404)
|
||||
|
||||
|
||||
class EnterpriseAPIForbiddenError(EnterpriseServiceError):
|
||||
"""Enterprise API returned 403 Forbidden."""
|
||||
|
||||
def __init__(self, description: str | None = None):
|
||||
def __init__(self, description: str = ""):
|
||||
super().__init__(description, status_code=403)
|
||||
|
||||
|
||||
class EnterpriseAPIUnauthorizedError(EnterpriseServiceError):
|
||||
"""Enterprise API returned 401 Unauthorized."""
|
||||
|
||||
def __init__(self, description: str | None = None):
|
||||
def __init__(self, description: str = ""):
|
||||
super().__init__(description, status_code=401)
|
||||
|
||||
|
||||
class EnterpriseAPIBadRequestError(EnterpriseServiceError):
|
||||
"""Enterprise API returned 400 Bad Request."""
|
||||
|
||||
def __init__(self, description: str | None = None):
|
||||
def __init__(self, description: str = ""):
|
||||
super().__init__(description, status_code=400)
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
class InvokeError(Exception):
|
||||
"""Base class for all LLM exceptions."""
|
||||
|
||||
description: str | None = None
|
||||
description: str = ""
|
||||
|
||||
def __init__(self, description: str | None = None):
|
||||
def __init__(self, description: str = ""):
|
||||
self.description = description
|
||||
|
||||
def __str__(self):
|
||||
|
||||
Reference in New Issue
Block a user