Example and copy-paste-fix for new comm error handler hook

This commit is contained in:
Gina Häußge committed 2018-02-28 17:14:06 +01:00
1 parent 2db2532c2f
commit b8e4ac21d0
1 file changed
+11 -1
+11 -1
View File
@@ -592,7 +592,7 @@ octoprint.comm.protocol.gcode.received
octoprint.comm.protocol.gcode.error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. py:function:: gcode_received_hook(comm_instance, error_message, *args, **kwargs)
.. py:function:: gcode_error_hook(comm_instance, error_message, *args, **kwargs)
Get the messages of any errors messages sent by the printer, with the leading ``Error:`` or ``!!`` already
stripped. Handlers should return True if they handled that error internally and it should not be processed by
@@ -602,6 +602,16 @@ octoprint.comm.protocol.gcode.error
Plugins might utilize this hook to handle errors generated by the printer that are recoverable in one way or
the other and should not trigger the normal handling that assumes the worst.
**Example:**
Looks for error messages containing "fan error" or "bed missing" (ignoring case) and marks them as handled by the
plugin.
.. onlineinclude:: https://raw.githubusercontent.com/OctoPrint/Plugin-Examples/master/comm_error_handler_test.py
:linenos:
:tab-width: 4
:caption: `comm_error_handler_test.py <https://github.com/OctoPrint/Plugin-Examples/blob/master/comm_error_handler_test.py>`_
:param MachineCom comm_instance: The :class:`~octoprint.util.comm.MachineCom` instance which triggered the hook.
:param str error_message: The error message received from the printer.
:return: True if the error was handled in the plugin and should not be processed further, False (or None) otherwise.