(20250102) Receipt add failures will be reported to Telegram.

This commit is contained in:
2025-01-02 12:14:11 +00:00
parent 1b8b15e9c1
commit aa01fd8c7a
2 changed files with 17 additions and 6 deletions
+15 -5
View File
@@ -175,7 +175,8 @@ class CoreBaseModel:
retry_count: int = 1,
backoff_seconds: float = 0.5,
backoff_multiplier: float = 1.1,
session_token: str = None
session_token: str = None,
alert_on_all_failures: bool = False
):
"""
@@ -209,7 +210,8 @@ class CoreBaseModel:
retry_count = retry_count,
backoff_seconds = backoff_seconds,
backoff_multiplier = backoff_multiplier,
session_token = session_token
session_token = session_token,
alert_on_all_failures = alert_on_all_failures
)
# If the database call succeeded, cache the response:
@@ -227,7 +229,8 @@ class CoreBaseModel:
retry_count: int = 1,
backoff_seconds: float = 0.5,
backoff_multiplier: float = 1.1,
session_token: str = None
session_token: str = None,
alert_on_all_failures: bool = False
):
"""
@@ -241,6 +244,7 @@ class CoreBaseModel:
:param session_token: A session token to share with the tech module when alerts need to be sent out for any
occurrence of exceptions. If this is passed, the tech module will be able to tell you which user faced the
issue.
:param alert_on_all_failures: If set to True, all failure (even non-exceptions) will be reported.
:return: The response from the stored procedure.
"""
@@ -262,8 +266,14 @@ class CoreBaseModel:
if not success or not self._debug_only_errors:
self._printer(proc_name, proc_args, success, exception, message)
# Send an alert out on exceptions:
if exception is not None:
# Send an alert out on exceptions or failures (if asked):
if (
exception is not None or
(
not success and
alert_on_all_failures
)
):
# Format the message in Markdown format:
exception_string = str(exception).replace("`", "'")