From e119f4990b3d598fc193ee97f279b56bd27741da Mon Sep 17 00:00:00 2001 From: Whispering Wind <151555003+ReturnFI@users.noreply.github.com> Date: Mon, 19 Aug 2024 00:55:15 +0330 Subject: [PATCH] Handle Error --- core/cli.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/cli.py b/core/cli.py index 947634c..709f93f 100644 --- a/core/cli.py +++ b/core/cli.py @@ -123,9 +123,11 @@ def add_user(username: str, traffic_limit: int, expiration_days: int, password: exit(1) if not creation_date: creation_date = datetime.now().strftime('%Y-%m-%d') - - run_cmd(['bash', Command.ADD_USER.value, username, str(traffic_limit), str(expiration_days), password, creation_date]) - + try: + run_cmd(['bash', Command.ADD_USER.value, username, str(traffic_limit), str(expiration_days), password, creation_date]) + except subprocess.CalledProcessError as e: + click.echo(f"{e.output.decode()}", err=True) + exit(1) @cli.command('edit-user') @click.option('--username', '-u', required=True, help='Username for the user to edit', type=str)