From 326bcab224e340946ea8eaac1ad8eff54840cc9f Mon Sep 17 00:00:00 2001 From: Akhil Narang Date: Mon, 25 Nov 2024 13:48:42 +0530 Subject: [PATCH] refactor: change some exceptions to simple echo + exits The traceback doesn't help in any meaningful way, just makes it harder to decipher the error Signed-off-by: Akhil Narang --- bench/app.py | 13 ++++++++----- bench/exceptions.py | 5 ----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/bench/app.py b/bench/app.py index e99eca95..b86ba8fc 100755 --- a/bench/app.py +++ b/bench/app.py @@ -23,7 +23,6 @@ import semantic_version as sv # imports - module imports import bench -from bench.exceptions import NotInBenchDirectoryError from bench.utils import ( UNSET_ARG, fetch_details_from_tag, @@ -706,10 +705,12 @@ def get_app( if not is_bench_directory(bench_path): if not init_bench: - raise NotInBenchDirectoryError( + click.secho( f"{os.path.realpath(bench_path)} is not a valid bench directory. " - "Run with --init-bench if you'd like to create a Bench too." + "Run with --init-bench if you'd like to create a Bench too.", + fg="red", ) + sys.exit(1) from bench.utils.system import init @@ -851,9 +852,11 @@ def install_resolved_deps( def new_app(app, no_git=None, bench_path="."): if bench.FRAPPE_VERSION in (0, None): - raise NotInBenchDirectoryError( - f"{os.path.realpath(bench_path)} is not a valid bench directory." + click.secho( + f"{os.path.realpath(bench_path)} is not a valid bench directory.", + fg="red", ) + sys.exit(1) # For backwards compatibility app = app.lower().replace(" ", "_").replace("-", "_") diff --git a/bench/exceptions.py b/bench/exceptions.py index 0465167c..ad8d7f3e 100644 --- a/bench/exceptions.py +++ b/bench/exceptions.py @@ -33,10 +33,5 @@ class CannotUpdateReleaseBench(ValidationError): class FeatureDoesNotExistError(CommandFailedError): pass - -class NotInBenchDirectoryError(Exception): - pass - - class VersionNotFound(Exception): pass