Skip to content

Commit

Permalink
Merge pull request #1598 from akhilnarang/exception-to-echo
Browse files Browse the repository at this point in the history
refactor: change some exceptions to simple echo + exits
  • Loading branch information
akhilnarang authored Nov 25, 2024
2 parents aae99fa + 326bcab commit fcf7210
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
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

0 comments on commit fcf7210

Please sign in to comment.