Custom override that applies custom formatting to the error message.
(self, message: str)
| 24 | super().__init__(*args, **kwargs) |
| 25 | |
| 26 | def error(self, message: str) -> NoReturn: |
| 27 | """Custom override that applies custom formatting to the error message.""" |
| 28 | lines = message.split("\n") |
| 29 | formatted_message = "" |
| 30 | for linum, line in enumerate(lines): |
| 31 | if linum == 0: |
| 32 | formatted_message = "Error: " + line |
| 33 | else: |
| 34 | formatted_message += "\n " + line |
| 35 | |
| 36 | self.print_usage(sys.stderr) |
| 37 | |
| 38 | # Format errors with warning style |
| 39 | formatted_message = stylize( |
| 40 | formatted_message, |
| 41 | style=styles.WARNING, |
| 42 | ) |
| 43 | self.exit(2, f"{formatted_message}\n\n") |
| 44 | |
| 45 | |
| 46 | if __name__ == "__main__": |