Skip to content

Commit

Permalink
Add exception handling
Browse files Browse the repository at this point in the history
  • Loading branch information
kamimanzoor committed Dec 15, 2019
1 parent a488fe6 commit 3c4d4d0
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions sonarcheck_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,18 @@ def notify_review_event(self, request, context):
change.head.path, request.commit_revision.head.hash, e)
continue

logger.debug("check_results %s", check_results)
for check in check_results:
for res in check_results[check]:
comments.append(
pb.Comment(
file=change.head.path,
line=(res.get("pos", {}) or {}).get("line", 0),
text="{}: {}".format(check, res["msg"])))
try:
comments.append(
pb.Comment(
file=change.head.path,
line=(res.get("pos", {}) or {}).get("line", 0),
text="{}: {}".format(check, res["msg"])))
except Exception as e:
logger.exception("Error occurred while creating a comment: %s", e)
continue

logger.info("%d comments produced", len(comments))

Expand Down

0 comments on commit 3c4d4d0

Please sign in to comment.