Enterprise Error Trapping

I have a Python script that submits data to the Apple servers to initiate a push notification to iOS devices and it’s been working perfectly.

BUT, if there’s an error communicating with the Apple servers, it creates an error that Python notes and passes on to Enterprise in the _UtilityLib’s RawShellScript procedure. For some reason the error never makes it further, causing Enterprise to fail with a cryptic error message “An error has occurred on the server RawShellScript _UtilityLib 2123” or an “Internal Server Error”. I don’t want the user to see the errors, preferring to handle it with a process of my own.

Debugging shows the error moves through this part of the RawShellScript procedure and exits on rtnerror - as it apparently should.

if AppleScriptResult matchexact "UNIX ERROR: "
local ErrorMessage
//giantmessage “!”+ErrorMessage
rawShellError=ErrorMessage /
use global variable to get around 255 char limit of rtnerror */
rtnerror ErrorMessage

I’ve been completely unable to trap it from there though. ErrorMessage has content but the process never seems to return to my procedure. Instead Enterprise goes no further. I can’t get the error as part of the script result. Using onerror, I’m able to record it precisely. The script and error show in the External Script wizard, etc. but I still can’t find a way to handle it gracefully.

I hope I haven’t set myself up for some other issue, but by disabling that section in the RawShellScript, I’ve suppressed Enterprise’s response to the error and can have my own procedure detect and handle the Python error.