Hi guys,
I am brand new to Prefect and trying to get familiar. I want my flow to finish in failed state but with a custom error message in the log and not the full exception detail:
from prefect import flow, task, get_run_logger
from prefect.orion.schemas.states import Failed
def my_function():
raise Exception('This is an exception')
@flow
def run_flow():
logger = get_run_logger()
try:
result = my_function()
<http://logger.info|logger.info>(result)
except Exception as e:
errmsg = f"Error! Type: {e.__class__.__name__} Detail: {e}"
logger.error(errmsg)
return Failed()
if __name__ == "__main__":
run_flow()
However, I get the following error;
Exception has occurred: TypeError
Unexpected result for failure state: None —— NoneType cannot be resolved into an exception
File "main.py", line 21, in <module>
run_flow()
I'm thinking I might be doing more than one thing wrong here. Can anyone enlighten me, please? Thanks!