error(message: string) Prints a usage message incorporating the message to stderr and exits. If you override this in a subclass, it should not return -- it should either exit or raise an exception.
(self, message)
| 2873 | _sys.exit(status) |
| 2874 | |
| 2875 | def error(self, message): |
| 2876 | """error(message: string) |
| 2877 | |
| 2878 | Prints a usage message incorporating the message to stderr and |
| 2879 | exits. |
| 2880 | |
| 2881 | If you override this in a subclass, it should not return -- it |
| 2882 | should either exit or raise an exception. |
| 2883 | """ |
| 2884 | self.print_usage(_sys.stderr) |
| 2885 | theme = self._get_theme(file=_sys.stderr) |
| 2886 | fmt = _('%(prog)s: error: %(message)s\n') |
| 2887 | fmt = fmt.replace('error: %(message)s', |
| 2888 | f'{theme.error}error:{theme.reset} {theme.message}%(message)s{theme.reset}') |
| 2889 | |
| 2890 | args = {'prog': self.prog, 'message': message} |
| 2891 | self.exit(2, fmt % args) |
| 2892 | |
| 2893 | def _warning(self, message): |
| 2894 | theme = self._get_theme(file=_sys.stderr) |
no test coverage detected