2
0
mirror of https://github.com/frappe/bench.git synced 2025-01-08 00:04:38 +00:00

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 <me@akhilnarang.dev>
This commit is contained in:
Akhil Narang 2024-11-25 13:48:42 +05:30
parent af8ed34201
commit 326bcab224
No known key found for this signature in database
GPG Key ID: 9DCC61E211BF645F
2 changed files with 8 additions and 10 deletions

View File

@ -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("-", "_")

View File

@ -33,10 +33,5 @@ class CannotUpdateReleaseBench(ValidationError):
class FeatureDoesNotExistError(CommandFailedError):
pass
class NotInBenchDirectoryError(Exception):
pass
class VersionNotFound(Exception):
pass