From d4a3cfe565deed150f0043ddca2e6883aa088ce4 Mon Sep 17 00:00:00 2001 From: Martin Levy Date: Fri, 9 Sep 2022 09:14:00 -0700 Subject: [PATCH] cleaned up error exit processing - because it was not correct --- cli4/cli4.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/cli4/cli4.py b/cli4/cli4.py index 0321bf7..22d1ddb 100644 --- a/cli4/cli4.py +++ b/cli4/cli4.py @@ -202,14 +202,14 @@ def run_command(cf, method, command, params=None, content=None, files=None): if len(e) > 0: # more than one error returned by the API for x in e: - sys.stderr.write('cli4: /%s - %d %s\n' % (command, x, x)) - sys.stderr.write('cli4: /%s - %d %s\n' % (command, int(e), e)) + sys.stderr.write('cli4: /%s - %d %s\n' % (command, int(x), str(x))) + sys.stderr.write('cli4: /%s - %d %s\n' % (command, int(e), str(e))) raise e except CloudFlare.exceptions.CloudFlareInternalError as e: - sys.stderr.write('cli4: InternalError: /%s - %d %s\n' % (command, int(e), e)) + sys.stderr.write('cli4: InternalError: /%s - %d %s\n' % (command, int(e), str(e))) raise e except Exception as e: - sys.stderr.write('cli4: /%s - %s - api error\n' % (command, e)) + sys.stderr.write('cli4: /%s - %s - api error\n' % (command, str(e))) raise e results.append(r) @@ -454,6 +454,7 @@ def do_it(args): except Exception as e: sys.exit(e) + exit_with_error = False for command in commands: try: results = run_command(cf, method, command, params, content, files) @@ -461,9 +462,10 @@ def do_it(args): except KeyboardInterrupt as e: sys.exit('cli4: %s - Interrupted\n' % (command)) except Exception as e: - if len(commands) > 1: - continue - sys.exit(e) + exit_with_error = True + + if exit_with_error: + sys.exit(1) def cli4(args): """Cloudflare API via command line"""