Activity Forums Salesforce® Discussions What possible failures do I need to handle when invoking a RemoteAction?

  • Gourav

    May 25, 2016 at 12:45 pm

    The canonical example of invoking a remote action shows three cases being handled: success, exception, and general failure:

    // just showing the handler passed to the remote action invocation, for brevity
    function(result, event){
    if (event.status) {
    // do something with result
    } else if (event.type === 'exception') {
    document.getElementById("responseErrors").innerHTML = event.message;
    } else {
    document.getElementById("responseErrors").innerHTML = event.message;

    Every example I've seen handles the else if and else cases identically. I can find no documentation of what values event.type may be when event.status is not true. Is this documented? Is there any reason I should not eliminate the "else if" block, and handle all failures in the same fashion (i.e., log the error)?

    I don't usually do the else if and I use a lot of @RemoteAction -- if you haven't handled the error on the server side and returned some useful exception code than there aren't any other known (documented) event.types

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos