Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: change some exceptions to simple echo + exits #1598

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions bench/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

# imports - module imports
import bench
from bench.exceptions import NotInBenchDirectoryError
from bench.utils import (
UNSET_ARG,
fetch_details_from_tag,
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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("-", "_")
Expand Down
5 changes: 0 additions & 5 deletions bench/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,5 @@ class CannotUpdateReleaseBench(ValidationError):
class FeatureDoesNotExistError(CommandFailedError):
pass


class NotInBenchDirectoryError(Exception):
pass


class VersionNotFound(Exception):
pass
Loading