From: Kefu Chai Date: Thu, 16 Apr 2015 10:29:00 +0000 (+0800) Subject: ceph.in: do not throw on unknown errno X-Git-Tag: v9.0.2~169^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F4375%2Fhead;p=ceph.git ceph.in: do not throw on unknown errno some of the errnos are not listed in errno.errorcode. if we happen to run into them, print 'Unknown' instead. Fixes: #11354 Signed-off-by: Kefu Chai --- diff --git a/src/ceph.in b/src/ceph.in index e3cc7b29bea2..317b259c07e9 100755 --- a/src/ceph.in +++ b/src/ceph.in @@ -407,7 +407,7 @@ def new_style_command(parsed_args, cmdargs, target, sigdict, inbuf, verbose): if ret: ret = abs(ret) print >> sys.stderr, \ - 'Error: {0} {1}'.format(ret, errno.errorcode[ret]) + 'Error: {0} {1}'.format(ret, errno.errorcode.get(ret, 'Unknown')) if outbuf: print outbuf if outs: @@ -838,11 +838,11 @@ def main(): sigdict, inbuf, verbose) if ret < 0: ret = -ret - print >> sys.stderr, prefix + 'Second attempt of previously successful command failed with {0}: {1}'.format(errno.errorcode[ret], outs) + print >> sys.stderr, prefix + 'Second attempt of previously successful command failed with {0}: {1}'.format(errno.errorcode.get(ret, 'Unknown'), outs) if ret < 0: ret = -ret - print >> sys.stderr, prefix + 'Error {0}: {1}'.format(errno.errorcode[ret], outs) + print >> sys.stderr, prefix + 'Error {0}: {1}'.format(errno.errorcode.get(ret, 'Unknown'), outs) if len(targets) > 1: final_ret = ret else: