Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

exceptions: Accept lazy translation as JsonableError argument.

Anders Kaseorgb85cb1e7004b
diff --git a/zerver/lib/exceptions.py b/zerver/lib/exceptions.py
index ffa356da429..7abcdbae030 100644
--- a/zerver/lib/exceptions.py
+++ b/zerver/lib/exceptions.py
@@ -1,8 +1,9 @@
from enum import Enum, auto
-from typing import Any, Dict, List, Optional, Tuple
+from typing import Any, Dict, List, Optional, Tuple, Union
from django.core.exceptions import ValidationError
from django.utils.translation import gettext as _
+from django_stubs_ext import StrPromise
class ErrorCode(Enum):
@@ -85,9 +86,9 @@ class JsonableError(Exception):
# like 403 or 404.
http_status_code: int = 400
- def __init__(self, msg: str) -> None:
+ def __init__(self, msg: Union[str, StrPromise]) -> None:
# `_msg` is an implementation detail of `JsonableError` itself.
- self._msg: str = msg
+ self._msg = msg
@staticmethod
def msg_format() -> str: