From b3fd05c465c4e933d07d41e40fc74164b69af901 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Sun, 3 Mar 2024 13:58:10 +0200 Subject: [PATCH] try-except --- pr_agent/algo/utils.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/pr_agent/algo/utils.py b/pr_agent/algo/utils.py index 61bde6f5..8edf74d2 100644 --- a/pr_agent/algo/utils.py +++ b/pr_agent/algo/utils.py @@ -28,19 +28,24 @@ def get_setting(key: str) -> Any: except Exception: return global_settings.get(key, None) + def emphasize_header(text: str) -> str: - # Finding the position of the first occurrence of ": " - colon_position = text.find(": ") + try: + # Finding the position of the first occurrence of ": " + colon_position = text.find(": ") - # Splitting the string and wrapping the first part in tags - if colon_position != -1: - # Everything before the colon (inclusive) is wrapped in tags - transformed_string = "" + text[:colon_position + 1] + "" + text[colon_position + 1:] - else: - # If there's no ": ", return the original string - transformed_string = text + # Splitting the string and wrapping the first part in tags + if colon_position != -1: + # Everything before the colon (inclusive) is wrapped in tags + transformed_string = "" + text[:colon_position + 1] + "" + text[colon_position + 1:] + else: + # If there's no ": ", return the original string + transformed_string = text - return transformed_string + return transformed_string + except Exception as e: + get_logger().exception(f"Failed to emphasize header: {e}") + return text def convert_to_markdown(output_data: dict, gfm_supported: bool=True) -> str: """