hey folks, Ive got a slack sensor using `make_slac...
# ask-community
r
hey folks, Ive got a slack sensor using
make_slack_on_failure_sensor
which I’m using to log failures. From
RunFailureSensorContext
I want to be able to extract the specific exception that caused an error. For example, in the screenshot you can see that it’s throwing a
KeyError
. I want to be able to grab this plus the error message. Is there a clean way to do this without having to use regex to parse the full stack trace which is returned from
RunFailureSensorContext.get_step_failure_events()[0].step_failure_data.error.cause
? I’ve tried grabbing other attributes from
step_failure data
but have only been able to snag the
DagsterExecutionStepExecutionError
as opposed to the key error. Any tips on how to accomplish this? I might be missing some obvious attribute here screenshot is below in the reply to illustrate what im trying to get 👇
Pasted Graphic.tiff
j
some other things you might try
Copy code
RunFailureSensorContext.get_step_failure_events()[0].event_specific_data.user_failure_data

RunFailureSensorContext.get_step_failure_events()[0].event_specific_data.error_source
also
Copy code
RunFailureSensorContext.get_step_failure_events()[0].event_specific_data.error_display_string
r
little bit hard to read so apologies here! unforuntately none of those get me exactly what im looking for. closest seems to be
event_specific_data.error_display_string
but that one gives the full stack trace as a string which isnt ideal lmk if there's others you'd recommend trying. otherwise ill go the regex route for now here's the output each one provides: ------------------------------------------
<http://step_failure_data.error.to|step_failure_data.error.to>_exception_message_only
: `dagster._core.errors.DagsterExecutionStepExecutionError: Error occurred while executing op "sanitized"
event_specific_data.user_failure_data
:
None
event_specific_data.error_source
: ErrorSource.USER_CODE_ERROR
event_specific_data.error_display_string
: `dagster._core.errors.DagsterExecutionStepExecutionError: Error occurred while executing op "example_client__core__axiontology_parquet":: KeyError: 'x' Stack Trace: full stack trace as a string is here
j
ok. sounds like the regex route will work. I’m not an expert on what’s kept in the failure data, but i dug through the source code and don’t see any other options
what does `
Copy code
context.failure_event.message
give you?