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

Clear error message in cli without traceback #5712

Closed
2 tasks done
Unintendedz opened this issue May 28, 2022 · 2 comments
Closed
2 tasks done

Clear error message in cli without traceback #5712

Unintendedz opened this issue May 28, 2022 · 2 comments
Labels
area/error-handling Bad error messages/insufficient error handling kind/feature Feature requests/implementations

Comments

@Unintendedz
Copy link

Unintendedz commented May 28, 2022

  • I have searched the issues of this repo and believe that this is not a duplicate.
  • I have searched the documentation and believe that my question is not covered.

Feature Request

Here is the prompt after I entered an incorrect option

 Stack trace:

  11  /usr/lib/python3/dist-packages/clikit/console_application.py:123 in run
      io = io_factory(

  ... some stack traces omitted

   1  /usr/lib/python3/dist-packages/clikit/args/default_args_parser.py:272 in _parse_short_option
      self._add_short_option(name, None, tokens, fmt, lenient)

  NoSuchOptionException


  The "-f" option does not exist.

  at /usr/lib/python3/dist-packages/clikit/args/default_args_parser.py:349 in _add_short_option
      345│     def _add_short_option(
      346│         self, name, value, tokens, fmt, lenient
      347│     ):  # type: (str, Optional[str], List[str], ArgsFormat, bool) -> None
      348│         if not fmt.has_option(name):
    → 349│             raise NoSuchOptionException(name)
      350│ 
      351│         self._add_long_option(
      352│             fmt.get_option(name).long_name, value, tokens, fmt, lenient
      353│         )

At the moment I have to scroll up to find out what I did wrong.

I wish there is an option or configuration make Poetry had just left the "-f" option does not exist. as a clear reminder of what I was doing wrong.

I am not a native English speaker and may not be able to use exact words and phrases to search for issues, Sorry if this issue is duplicated.
I have reading the following sections of the documentation but did not find an option that would be helpful for my needs.

Did I miss something? Any help would be appreciated.

@Unintendedz Unintendedz added kind/feature Feature requests/implementations status/triage This issue needs to be triaged labels May 28, 2022
@mkniewallner mkniewallner added area/error-handling Bad error messages/insufficient error handling and removed status/triage This issue needs to be triaged labels May 29, 2022
@mkniewallner
Copy link
Member

This has been changed in the to be released version 1.2 of Poetry, where the stack trace is only shown when passing -v (for verbose).

$ poetry show -f

  NoSuchOptionException

  The option "-f" does not exist

  at ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/cleo/io/inputs/argv_input.py:262 in _add_short_option
      258│             raise RuntimeException(message)
      259│ 
      260│     def _add_short_option(self, shortcut: str, value: Any) -> None:
      261│         if not self._definition.has_shortcut(shortcut):
    → 262│             raise NoSuchOptionException(f'The option "-{shortcut}" does not exist')
      263│ 
      264│         self._add_long_option(
      265│             self._definition.option_for_shortcut(shortcut).name, value
      266│         )
$ poetry show -f -v
Using virtualenv: <REDACTED>

  Stack trace:

  9  ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/cleo/application.py:330 in run
       exit_code = self._run(io)

  [...]

  1  ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/cleo/io/inputs/argv_input.py:188 in _parse_short_option
       self._add_short_option(name, None)

  NoSuchOptionException

  The option "-f" does not exist

  at ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/cleo/io/inputs/argv_input.py:262 in _add_short_option
      258│             raise RuntimeException(message)
      259│ 
      260│     def _add_short_option(self, shortcut: str, value: Any) -> None:
      261│         if not self._definition.has_shortcut(shortcut):
    → 262│             raise NoSuchOptionException(f'The option "-{shortcut}" does not exist')
      263│ 
      264│         self._add_long_option(
      265│             self._definition.option_for_shortcut(shortcut).name, value
      266│         )

There is also python-poetry/cleo#132 to even further improve error handling.
#2854 and #5229 are also similar requests.

Copy link

github-actions bot commented Mar 2, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/error-handling Bad error messages/insufficient error handling kind/feature Feature requests/implementations
Projects
None yet
Development

No branches or pull requests

2 participants