Results 1 to 6 of 6

Thread: Is it possible to send custom error message if the load request of Store fails

  1. #1

    Default Is it possible to send custom error message if the load request of Store fails

    Hi

    I am using Ext.data.Store for fetching different options of a Combo Box at multiple places in my app. In the Reader configured with the Store we can specify the schema for the response received by the configured Proxy. But if there is an error/exception at the server side i am only able to know whether the AJAX request succeded or failed by the checking the success parameter in the callback function specified at the time of load call.

    I have seen the different arguments we can have in the callback function of a load's call or an event handler specified for the load event.

    I may be missing something, it will be very helpful in the app i am developing.

  2. #2
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854

    Default

    You can add a handler for the loadexception event if you're trying to catch status code that are not in 200-299.

  3. #3
    Sencha User hendricd's Avatar
    Join Date
    Aug 2007
    Location
    Long Island, NY USA
    Posts
    5,966

    Default

    There are a number of ways to handle it, but as a practical matter, every store should have a 'loadexception' event defined. If anything goes wrong during the Ajax request or during eval of the response, the loadexception event will fire.

    If your serverScript decides it can't handle the request properly, the easiest thing to do is return an 'unseccessful' HTTP status in the response (say 410 or something). Then, the stores' loadexception event would be raised.
    "be dom-ready..."
    Doug Hendricks

    Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.


    Got Sencha licensing questions? Find out more here.


  4. #4

    Default

    Thanks tryanDLS and hendricd for suggestions

    I added an event handler for the loadexception event. Tested various possible error scenarios.
    The loadexception event handler takes dataproxy, data, callback and exception as arguments.
    From callback. status and statusText i was able to know about the error codes and descriptions.

    But i am trying to send the root exception cause or if possible the whole stack trace in the json response from the server.
    In my existing app which use jsps i have an error page which have a details button, which when clicked shows the whole
    error stack trace to the user. The user can simply copy that stack trace and send it to the Support team.

    I was wondering whether i will be able to do the same thing with extJS.

    Maybe using callback.responseText i might be able to do this.
    Please let me know your views.

  5. #5

    Default not proxy's exception,but only returned wrong data. how ext process?

    in my test ,no process,and can't process ,

    it's be treated as empty recordset.

  6. #6
    Sencha User hendricd's Avatar
    Join Date
    Aug 2007
    Location
    Long Island, NY USA
    Posts
    5,966

    Default

    @Spider - Sure, just include your serverSide stack trace in the JSON reponse:
    Code:
    {success:false,
     criticalException:true,
     stackTrace:[    ]
    }
    .. and send it back with a 409? http status. Then loadexception will see the response, and you can handle it any way you want.
    "be dom-ready..."
    Doug Hendricks

    Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.


    Got Sencha licensing questions? Find out more here.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •