Skip to content

Commit 228eb92

Browse files
committed
no need for try/catch
1 parent fdecf88 commit 228eb92

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

ack_backend/src/logging_decorators.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -86,19 +86,14 @@ def wrapper(*args, **kwargs):
8686
base_log_data = {"function_name": f"ack_processor_{func.__name__}", "date_time": str(datetime.now())}
8787
start_time = time.time()
8888

89-
try:
90-
result = func(*args, **kwargs)
91-
if result is not None:
92-
message_for_logs = "Record processing complete"
93-
base_log_data.update(result)
94-
additional_log_data = {"status": "success", "statusCode": 200, "message": message_for_logs}
95-
generate_and_send_logs(start_time, base_log_data, additional_log_data)
96-
return result
97-
98-
except Exception as error:
99-
additional_log_data = {"status": "fail", "statusCode": 500, "diagnostics": str(error)}
100-
generate_and_send_logs(start_time, base_log_data, additional_log_data, is_error_log=True)
101-
raise
89+
# NB this doesn't require a try-catch block as the wrapped function never throws an exception
90+
result = func(*args, **kwargs)
91+
if result is not None:
92+
message_for_logs = "Record processing complete"
93+
base_log_data.update(result)
94+
additional_log_data = {"status": "success", "statusCode": 200, "message": message_for_logs}
95+
generate_and_send_logs(start_time, base_log_data, additional_log_data)
96+
return result
10297

10398
return wrapper
10499

0 commit comments

Comments
 (0)