From aa01fd8c7a2a08868c1fd695e04c789afbfc5b59 Mon Sep 17 00:00:00 2001 From: khushal Date: Thu, 2 Jan 2025 12:14:11 +0000 Subject: [PATCH] (20250102) Receipt add failures will be reported to Telegram. --- controllers_v2/core/base.py | 20 ++++++++++++++----- controllers_v2/finstitutions/payments/base.py | 3 ++- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/controllers_v2/core/base.py b/controllers_v2/core/base.py index 16f17cf..bbec944 100644 --- a/controllers_v2/core/base.py +++ b/controllers_v2/core/base.py @@ -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("`", "'") diff --git a/controllers_v2/finstitutions/payments/base.py b/controllers_v2/finstitutions/payments/base.py index 4b432a4..97f231b 100644 --- a/controllers_v2/finstitutions/payments/base.py +++ b/controllers_v2/finstitutions/payments/base.py @@ -348,7 +348,8 @@ class PaymentsController(CoreAuthTokenController, ABC): retry_count = 1, backoff_seconds = 0.5, backoff_multiplier = 1.1, - session_token = session_token + session_token = session_token, + alert_on_all_failures = True ) print("RECEIPT ADD JSON:", json.to_string(sql_json, default = str))