From 53514ad97f6f75746613f09d464f69a7c31bed55 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Thu, 16 Apr 2015 18:29:00 +0800 Subject: [PATCH] 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 --- src/ceph.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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: -- 2.47.3