Error Callback Function

The error callback function is a function you specify in the error parameters object. The error callback function is called when SWF Studio encounters an error in an asynchronous command made using the ActionScript API.

The error callback function receives three arguments: a return object, a callback return object, and an error return object. Each of these arguments is an object that contains various properties you can access.

When you specify a callback function (using the callback parameters object) and an error callback function together, the error callback function is called when a command fails instead of the callback function.

The error return object contains one special property, called resume, that is only available to the error callback function. This is actually a method that will call the callback function as if it was called directly instead of being called via the resume method (as if no error callback function was specified). This is useful to test for conditions where an "acceptable" failure occurs.

One example where this is useful is when an error occurs when executing ssCore.FTP.transfer. You might want to test to see if the error code is 24, which indicates "Transfer aborted by user request". In this case the error is recoverable and should not stop your application. In that case you would call the resume method so that your application would continue uninterrupted.

Error callback functions are also useful for generalized error handling. Instead of writing error handling in every callback function you could pass the same error callback object, pointing to the same error callback function, to a number of commands and have the error callback function handle any error that is encountered. In this way, you simplify your callback functions because they do not need to test for success or failure, they will only be called if the command was successful.