From add0f1e5e229c9ad66e8ef77ad59e0e390e20db6 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 (cherry picked from commit 53514ad97f6f75746613f09d464f69a7c31bed55) --- src/ceph.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ceph.in b/src/ceph.in index 2b6adf4dc579a..51b2a39877d2c 100755 --- a/src/ceph.in +++ b/src/ceph.in @@ -459,7 +459,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: @@ -858,11 +858,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.39.5