mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 22:13:26 +00:00
webhooks: Log unexpected webhook events separately.
This change serves to declutter webhook-errors.log, which is filled with too many UnexpectedWebhookEventType exceptions. Keeping UnexpectedWebhookEventType in zerver/lib/webhooks/common.py led to a cyclic import when we tried to import the exception in zerver/decorators.py, so this commit also moves this exception to another appropriate module. Note that our webhooks still import this exception via zerver/lib/webhooks/common.py.
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
from enum import Enum
|
||||
from typing import Any, Dict, List, Type
|
||||
from typing import Any, Dict, List, Type, Optional
|
||||
from mypy_extensions import NoReturn
|
||||
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
|
||||
class AbstractEnum(Enum):
|
||||
'''An enumeration whose members are used strictly for their names.'''
|
||||
|
||||
@@ -200,3 +201,15 @@ class InvalidAPIKeyError(JsonableError):
|
||||
@staticmethod
|
||||
def msg_format() -> str:
|
||||
return _("Invalid API key")
|
||||
|
||||
class UnexpectedWebhookEventType(JsonableError):
|
||||
code = ErrorCode.UNEXPECTED_WEBHOOK_EVENT_TYPE
|
||||
data_fields = ['webhook_name', 'event_type']
|
||||
|
||||
def __init__(self, webhook_name: str, event_type: Optional[str]) -> None:
|
||||
self.webhook_name = webhook_name
|
||||
self.event_type = event_type
|
||||
|
||||
@staticmethod
|
||||
def msg_format() -> str:
|
||||
return _("The '{event_type}' event isn't currently supported by the {webhook_name} webhook")
|
||||
|
||||
Reference in New Issue
Block a user