MessageHandlerCollect
MessageHandlerCollect()
Bases: MessageHandler
Message handler that collects messages in a list.
capture_exceptions(code)
Run code and capture any exceptions as error messages.
Exceptions with empty messages are not reported as error messages but still mark the handler as failed.
| PARAMETER | DESCRIPTION |
|---|---|
code
|
The function to run.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if code ran without exceptions, False otherwise. |
error(message, file=None, position=None, position_end=None)
Report an error and mark current script as failed.
| PARAMETER | DESCRIPTION |
|---|---|
message
|
The error message.
TYPE:
|
file
|
The file where the error occurred.
TYPE:
|
position
|
The position in the file where the error occurred.
TYPE:
|
position_end
|
The end position in the file where the error occurred.
TYPE:
|
error_from_exception(exception, omit_empty=False)
Print message from exception.
If the exception is a FilePositionException, the file and position information will be used.
| PARAMETER | DESCRIPTION |
|---|---|
exception
|
The exception to print the message from.
TYPE:
|
omit_empty
|
Whether to omit messages with empty text. Handler will still be marked as failed.
TYPE:
|
fail()
Mark the message handler as failed.
has_failed()
Check if the message handler has failed (errors reported).
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if the message handler has failed, False otherwise. |
info(message, file=None, position=None, position_end=None)
Print informational message using current script.
| PARAMETER | DESCRIPTION |
|---|---|
message
|
Informational message.
TYPE:
|
file
|
The file where the message occurred.
TYPE:
|
position
|
The position in the file where the message occurred.
TYPE:
|
position_end
|
The end position in the file where the message occurred.
TYPE:
|
is_ok()
Check if the message handler is ok (no errors reported).
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if the message handler is ok, False otherwise. |
reset()
Reset the message handler to ok.
warning(message, file=None, position=None, position_end=None)
Print warning using current script.
| PARAMETER | DESCRIPTION |
|---|---|
message
|
Warning message.
TYPE:
|
file
|
The file where the warning occurred.
TYPE:
|
position
|
The position in the file where the warning occurred.
TYPE:
|
position_end
|
The end position in the file where the warning occurred.
TYPE:
|