happyly.handling.handler.Handler¶
-
class
happyly.handling.handler.
Handler
¶ Bases:
abc.ABC
A class containing logic to handle a parsed message.
handle
(message)Applies logic using a provided message, optionally gives back one or more results.
on_handling_failed
(message, error)Applies fallback logic using a provided message when
handle()
fails, optionally gives back one or more results.-
handle
(message)¶ Applies logic using a provided message, optionally gives back one or more results. Each result consists of message attributes which can be serialized and sent. When fails, calls
on_handling_failed()
-
on_handling_failed
(message, error)¶ Applies fallback logic using a provided message when
handle()
fails, optionally gives back one or more results. Enforces users ofHandler
class to provide explicit strategy for errors.If you want to propagate error further to the underlying Executor/Handler, just re-raise an
error
here:def on_handling_failed(self, message, error): raise error
-