Sometimes my script based synthetic monitoring fails without proper details

I have a script that pings several endpoints based on certain parameters, but sometimes it fails to state UnknownError with a not very helpful script log. How do I debug this?