bench icon indicating copy to clipboard operation
bench copied to clipboard

Consider reducing verbosity of "NotInBenchDirectoryError" failures

Open rahulporuri opened this issue 4 months ago • 1 comments

Is your feature request related to a problem? Please describe. Over the past 24 hours, I have created 10s of benches, and every single time I have forgetten to CD-into the bench directory before running bench get-app. The error message clearly conveys what the problem might be and what needs to be done but the traceback included in the error message provides no meaningful information.

Describe the solution you'd like Remove the traceback from the error message.

Describe alternatives you've considered N/A

Additional context

rahulporuri@serenity:~/frappe-benches$ bench get-app https://github.com/fossunited/fossunited
ERROR: /home/rahulporuri/frappe-benches is not a valid bench directory. Run with --init-bench if you'd like to create a Bench too.
Traceback (most recent call last):
  File "/home/rahulporuri/python-venvs/fossunited-bench/bin/bench", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/home/rahulporuri/python-venvs/fossunited-bench/lib/python3.11/site-packages/bench/cli.py", line 132, in cli
    bench_command()
  File "/home/rahulporuri/python-venvs/fossunited-bench/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rahulporuri/python-venvs/fossunited-bench/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/home/rahulporuri/python-venvs/fossunited-bench/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rahulporuri/python-venvs/fossunited-bench/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rahulporuri/python-venvs/fossunited-bench/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rahulporuri/python-venvs/fossunited-bench/lib/python3.11/site-packages/bench/commands/make.py", line 181, in get_app
    get_app(
  File "/home/rahulporuri/python-venvs/fossunited-bench/lib/python3.11/site-packages/bench/app.py", line 709, in get_app
    raise NotInBenchDirectoryError(
bench.exceptions.NotInBenchDirectoryError: /home/rahulporuri/frappe-benches is not a valid bench directory. Run with --init-bench if you'd like to create a Bench too.

Please note that only two of the lines above are meaningful - the command and the line immediately after the command which provides the meaningful error message. the rest of the lines are basically noise.

Note the maintainers : happy to contribute this change if the maintainers think it's a meaningful addition

rahulporuri avatar Oct 22 '24 13:10 rahulporuri