Re-export more Click exception types #1832
Unanswered
BenjyWiener
asked this question in
Questions
Replies: 1 comment
-
|
this is probably the closest current maintainer signal: #1816 (comment) The short version there is that #1790 is also a useful precedent: |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
First Check
Example Code
# N/ADescription
There are currently a number of exceptions that Typer can raise which are no longer exported by
typer, includingUsageErrorand most of its subclasses.In my code I currently catch
click.NoSuchOptionin order to show a better error message for options that were used in the wrong subcommand (my-cli sub --optinstead ofmy-cli --opt sub).I have global error handler that handles common errors, printing tracebacks and extra information only for unknown exceptions using a catch-all
except BaseException. I currently catch and re-raiseclick.Exceptionso that CLI errors don't get handled by the catch-all.I also use
click.ClickException.error_codeandclick.UsageError.exit_codeto ensure that my specific error codes don't conflict with those used by Typer/Click.All of these require accessing
typer._clickon typer 0.26.I suggest renaming
ClickExceptiontoTyperExceptionand re-exporting all of the following:TyperExceptionUsageErrorNoSuchOptionBadOptionUsageBadArgumentUsageOperating System
Other
Operating System Details
No response
Project Version
0.26.7
Python Version
3.14
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions