can no longer handle errors returned from apple events?

Hi Folks,

I’m still working to bring an old app forward to cocoa. It’s going very well but something seems to be fundamentally different on cocoa with apple event error handling. Previously if a verb did not complete I simply returned false at the end of the HandleAppleEvent routine. Then you could trap that and handle it in the script itself by using the try/on error block. This no longer works for me at all. I return false and the script just keeps running as if the verb completed. Unless the verb is returning data in which case an unable to convert error will trigger it when it tries to make a null response into a string or something. But verbs that do not return data will not trigger the error handler! This is a rather significant departure from the norm.

Is it that I’m not returning an actual error reply? Simply returning false to the handle apple event in Xojo may not be enough anymore? Has anybody noticed anything similar? I see that the documentation of the appleevent object in the language reference now contains instructions for getting and setting error information in the reply, but the only examples seem to be how to parse out errors from other sources and not how to generate them properly yourself.

I’ll just answer my own question :wink: Yes, I dont know if it’s a cocoa thing or a 10.9 thing, but simply returning false after handling an event no longer triggers the try/on error handling. You must instead add an “errn” descriptor that holds an integer describing the error number in order to actually cause an error to be handled. At the end of the routine you must return true as well.