From 69eee348209a7a88c9208c9f37c634ef4591e02e Mon Sep 17 00:00:00 2001 From: Peter Mosmans Date: Tue, 23 Aug 2016 11:26:48 +0200 Subject: [PATCH] Fail safely when no issues can be found Note that it's a bare except... not so nice --- chatops/python/gitlab-to-pentext.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/chatops/python/gitlab-to-pentext.py b/chatops/python/gitlab-to-pentext.py index a44f10f..5ba2a14 100644 --- a/chatops/python/gitlab-to-pentext.py +++ b/chatops/python/gitlab-to-pentext.py @@ -140,13 +140,16 @@ def list_issues(gitserver, options): """ Lists all issues for options['issues'] """ - for issue in gitserver.projects.get(options['issues']).issues.list(all=True): - if issue.state != 'opened' and not options['closed']: - continue - if 'finding' in issue.labels: - add_finding(issue, options) - if 'non-finding' in issue.labels: - add_non_finding(issue, options) + try: + for issue in gitserver.projects.get(options['issues']).issues.list(all=True): + if issue.state != 'opened' and not options['closed']: + continue + if 'finding' in issue.labels: + add_finding(issue, options) + if 'non-finding' in issue.labels: + add_non_finding(issue, options) + except: + print_error('could not find any issues', -1) def list_projects(gitserver, options):