Skip to content

Commit

Permalink
feat: Add exception handling for discussion creation in gitlab_provid…
Browse files Browse the repository at this point in the history
…er.py
  • Loading branch information
mrT23 committed Dec 11, 2023
1 parent b8cc110 commit 02c0c89
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pr_agent/git_providers/gitlab_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,11 @@ def send_inline_comment(self,body: str,edit_type: str,found: bool,relevant_file:
pos_obj['new_line'] = target_line_no - 1
pos_obj['old_line'] = source_line_no - 1
get_logger().debug(f"Creating comment in {self.id_mr} with body {body} and position {pos_obj}")
self.mr.discussions.create({'body': body, 'position': pos_obj})
try:
self.mr.discussions.create({'body': body, 'position': pos_obj})
except Exception as e:
get_logger().debug(
f"Failed to create comment in {self.id_mr} with position {pos_obj} (probably not a '+' line)")

def get_relevant_diff(self, relevant_file: str, relevant_line_in_file: int) -> Optional[dict]:
changes = self.mr.changes() # Retrieve the changes for the merge request once
Expand Down

0 comments on commit 02c0c89

Please sign in to comment.