Files
dify-plugin-sdks/python/dify_plugin/errors/trigger.py
T
Harry 1fa18bfd1c refactor(trigger): update trigger error handling and response types
- Renamed `WebhookValidationError` to `TriggerValidationError` for consistency in error handling across trigger operations.
- Updated references to the new `TriggerValidationError` in the GitHub provider and trigger interfaces.
- Enhanced the `TriggerProvider` class to raise the new validation error for webhook signature issues.
- Adjusted the `IssueCommentTrigger` to return the correct event response type.
- Improved type hints and imports in various modules for better clarity and organization.
2025-09-03 14:04:33 +08:00

59 lines
1.6 KiB
Python

"""
Exceptions for trigger-related operations
"""
class TriggerError(Exception):
"""Base exception for all trigger-related errors"""
pass
class SubscriptionError(TriggerError):
"""
Raised when trigger subscription operations fail.
This exception is raised for various subscription failures:
- Invalid credentials or authentication failures
- Network errors when contacting external services
- Invalid subscription parameters
- External service API errors (rate limits, service unavailable, etc.)
"""
def __init__(self, message: str, error_code: str | None = None, external_response: dict | None = None):
"""
Initialize SubscriptionError with detailed information.
Args:
message: Human-readable error description
error_code: Machine-readable error code for categorization
external_response: Raw response from external service (if available)
"""
super().__init__(message)
self.error_code = error_code
self.external_response = external_response
class TriggerValidationError(TriggerError):
"""
Raised when webhook signature validation fails.
This indicates potential security issues where the webhook
request cannot be verified as coming from the expected source.
"""
pass
class TriggerDispatchError(TriggerError):
"""
Raised when event dispatching fails.
This can occur when:
- Event payload cannot be parsed
- Event type cannot be determined
- Required headers are missing
"""
pass