Returns a new exception of the specified type from the point at which it is invoked, with the specified formatted message as the reason. The resulting exception will have its cause set to the Message object on which error() was called. Additionally, if that message is a Requ
(self, exc_type, format_string, *args, **kwargs)
| 499 | return command == () or self.request.command in command |
| 500 | |
| 501 | def error(self, exc_type, format_string, *args, **kwargs): |
| 502 | """Returns a new exception of the specified type from the point at which it is |
| 503 | invoked, with the specified formatted message as the reason. |
| 504 | |
| 505 | The resulting exception will have its cause set to the Message object on which |
| 506 | error() was called. Additionally, if that message is a Request, a failure |
| 507 | response is immediately sent. |
| 508 | """ |
| 509 | |
| 510 | assert issubclass(exc_type, MessageHandlingError) |
| 511 | |
| 512 | silent = kwargs.pop("silent", False) |
| 513 | reason = format_string.format(*args, **kwargs) |
| 514 | exc = exc_type(reason, self, silent) # will log it |
| 515 | |
| 516 | if isinstance(self, Request): |
| 517 | self.respond(exc) |
| 518 | return exc |
| 519 | |
| 520 | def isnt_valid(self, *args, **kwargs): |
| 521 | """Same as self.error(InvalidMessageError, ...).""" |
no test coverage detected