Echo an error string on the CLI. Args: text: Input text string. Raises: StyledClickException: when called.
(text: str)
| 192 | |
| 193 | |
| 194 | def error(text: str) -> NoReturn: |
| 195 | """Echo an error string on the CLI. |
| 196 | |
| 197 | Args: |
| 198 | text: Input text string. |
| 199 | |
| 200 | Raises: |
| 201 | StyledClickException: when called. |
| 202 | """ |
| 203 | error_prefix = click.style("Error: ", fg="red", bold=True) |
| 204 | error_message = click.style(text, fg="red", bold=False) |
| 205 | |
| 206 | class StyledClickException(click.ClickException): |
| 207 | def show(self, file: Optional[IO[Any]] = None) -> None: |
| 208 | if file is None: |
| 209 | file = click.get_text_stream("stderr") |
| 210 | click.echo(self.message, file=file) |
| 211 | |
| 212 | raise StyledClickException(message=error_prefix + error_message) |
| 213 | |
| 214 | |
| 215 | def exception(exception: Exception) -> NoReturn: |
no test coverage detected