gerrit: inspect: handle CLs that do not exist
If you try to inspect a CL that doesn't exist (like 1231241251), you get
an ugly traceback. Print out a proper message instead.
BUG=chromium:327217
TEST=`gerrit inspect 1` shows nice message now instead of traceback
Change-Id: I2f80d27c3355e64f3b0b5b9e006522028625e56d
Reviewed-on: https://chromium-review.googlesource.com/185581
Reviewed-by: Yu-Ju Hong <yjhong@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
diff --git a/scripts/gerrit.py b/scripts/gerrit.py
index afc8263..f9cff3c 100644
--- a/scripts/gerrit.py
+++ b/scripts/gerrit.py
@@ -205,7 +205,11 @@
def UserActInspect(opts, idx):
"""Inspect CL number <n>"""
- PrintCl(opts, FilteredQuery(opts, idx)[0], None)
+ cl = FilteredQuery(opts, idx)
+ if cl:
+ PrintCl(opts, cl[0], None)
+ else:
+ print('no results found for CL %s' % idx)
def UserActReview(opts, idx, num):