Splunk AppDynamics

How to set job as failed if exception occurs

rbarnespancanal
Explorer

Hi,

I have a synthetic script that sometimes ends a run as a "broken job". I see in the documentation that this happens because of an unhandled exception.

So I added:

try:

....

     wait.until(EC.element_to_be_clickable((By.ID, "username"))).click()

except Exception as e:
    print ("The script threw an exception.")

But now, the script runs and if the job has a timeout exception the job status shows as "success", but I can see in the script output that it printed "The script threw an exception."

How do I make it so that if an exception is thrown the script status shows as failed?

Thanks,

Roberto

Labels (1)
0 Karma
1 Solution

tezza_chen
Path Finder

This may not be elegant... Try to include an assertion in the exception handling to see if it works:

except Exception as e:
    print ("The script threw an exception.")
    assert False,"other exception"

 After the job ran, you will notice the session fails because of assertion failure.

image.png

regards,

Terence

View solution in original post

rbarnespancanal
Explorer

Hi Terence,

Your solution seems to be working fine.

Thanks,

Roberto

0 Karma

tezza_chen
Path Finder

This may not be elegant... Try to include an assertion in the exception handling to see if it works:

except Exception as e:
    print ("The script threw an exception.")
    assert False,"other exception"

 After the job ran, you will notice the session fails because of assertion failure.

image.png

regards,

Terence

Get Updates on the Splunk Community!

Uncovering Multi-Account Fraud with Splunk Banking Analytics

Last month, I met with a Senior Fraud Analyst at a nationally recognized bank to discuss their recent success ...

Secure Your Future: A Deep Dive into the Compliance and Security Enhancements for the ...

What has been announced?  In the blog, “Preparing your Splunk Environment for OpensSSL3,”we announced the ...

New This Month in Splunk Observability Cloud - Synthetic Monitoring updates, UI ...

This month, we’re delivering several platform, infrastructure, application and digital experience monitoring ...