https://prefect.io logo
Title
d

Dean Magee

05/19/2021, 11:57 PM
Hi There, Im trying to use a state handler to send an error message to MS Teams when a task fails...
def alert_failed(obj, old_state, new_state):
if new_state.is_failed():
myTeamsMessage = pymsteams.connectorcard(os.getenv("MSTEAMS_WEBHOOK_URL"))
myTeamsMessage.title("An error has occurred!")
Im trying to grab the text that Python spits out as an error message and include that in my MS Teams message. Any idea how to do that?
c

Chris White

05/20/2021, 12:06 AM
Hi Dean - you can try using
new_state.result
which should be an
Exception
type; you can then convert to a string using either
str(new_state.result)
or
repr(new_state.result)