Skip to content

Commit

Permalink
cleaned up error exit processing - because it was not correct
Browse files Browse the repository at this point in the history
  • Loading branch information
mahtin committed Sep 9, 2022
1 parent b15d20c commit d4a3cfe
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions cli4/cli4.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -454,16 +454,18 @@ 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)
write_results(results, output)
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"""
Expand Down

0 comments on commit d4a3cfe

Please sign in to comment.