commit 51c5cc2936ce1507de1c554f4e6ec00dd5877ae9 parent c7670e38e8c79ff7e8df604949069fb04c43d7e6 Author: MS <ms@taler.net> Date: Thu, 27 May 2021 13:57:37 +0200 cli helper function Diffstat:
| M | cli/bin/libeufin-cli | | | 12 | ++++++++++-- |
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/cli/bin/libeufin-cli b/cli/bin/libeufin-cli @@ -12,8 +12,16 @@ from urllib.parse import urljoin from getpass import getpass -def tell_user(resp, withsuccess=False): - if resp.status_code != 200: +# Exit the program according to the HTTP status code that +# was received. +def managed_exit(received_status_code, expected_status_code=200): + if received_status_code != expected_status_code: + sys.exit(1) + sys.exit(0) + + +def tell_user(resp, expected_status_code=200, withsuccess=False): + if resp.status_code != expected_status_code: print(resp.content.decode("utf-8")) return if withsuccess: