MCPcopy
hub / github.com/pallets/click / ClickException

Class ClickException

src/click/exceptions.py:35–65  ·  view source on GitHub ↗

An exception that Click can handle and show to the user.

Source from the content-addressed store, hash-verified

33
34
35class ClickException(Exception):
36 """An exception that Click can handle and show to the user."""
37
38 #: The exit code for this exception.
39 exit_code: t.ClassVar[int] = 1
40
41 show_color: t.Final[bool | None]
42 message: t.Final[str]
43
44 def __init__(self, message: str) -> None:
45 super().__init__(message)
46 # The context will be removed by the time we print the message, so cache
47 # the color settings here to be used later on (in `show`)
48 self.show_color = resolve_color_default()
49 self.message = message
50
51 def format_message(self) -> str:
52 return self.message
53
54 def __str__(self) -> str:
55 return self.message
56
57 def show(self, file: t.IO[t.Any] | None = None) -> None:
58 if file is None:
59 file = get_text_stderr()
60
61 echo(
62 _("Error: {message}").format(message=self.format_message()),
63 file=file,
64 color=self.show_color,
65 )
66
67
68class UsageError(ClickException):

Callers 1

edit_filesMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…