exceptions: Create base class ExpectationMismatchError.

This class will be inherited by all errors related to
some sort of mismatch from the expected value.

This is a prep commit for #33051, as a part of which we
add a new exception class for message content mismatch.
This commit is contained in:
Kislay Verma
2025-03-28 09:20:50 +05:30
committed by Tim Abbott
parent 1f19ea6454
commit 5b5be39b19

View File

@@ -684,16 +684,29 @@ class TopicWildcardMentionNotAllowedError(JsonableError):
return _("You do not have permission to use topic wildcard mentions in this topic.")
class PreviousSettingValueMismatchedError(JsonableError):
class ExpectationMismatchError(JsonableError):
code: ErrorCode = ErrorCode.EXPECTATION_MISMATCH
data_fields = ["field_name"]
def __init__(self) -> None:
pass
self.field_name = "field"
@staticmethod
@override
def msg_format() -> str:
return _("'old' value does not match the expected value.")
return _("'{field_name}' value does not match the expected value.")
class PreviousSettingValueMismatchedError(ExpectationMismatchError):
def __init__(self) -> None:
super().__init__()
self.field_name = "old"
class PreviousMessageContentMismatchedError(ExpectationMismatchError):
def __init__(self) -> None:
super().__init__()
self.field_name = "prev_content_sha256"
class SystemGroupRequiredError(JsonableError):