[CLOSED] Problem when trying to show an error captured by the loader Listener named 'Exception'.

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] Problem when trying to show an error captured by the loader Listener named 'Exception'.

    Last edited by Daniil; Jun 26, 2012 at 9:22 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Well, or parse that raw responseText on client via JavaScript or catch the Exception on server and send some response which would be easily to parse.

    I would prefer the second approach - catching on server.
  3. #3
    I tried to, but...

    Wich one should I use? I tried AjaxResult but didn't work out pretty well.

    Thanks in advance,
  4. #4
    Well, any one that could be easily parsed within the Exception listener.

    You could just send a ContentResult with just an error message.
  5. #5
    O.O Niiiiceee...

    But tell me, how the Exception listener was fired if I did not threw any exception? (I catched the exception then "return new ContentResult { Content = ex.Message };")

    Just curious, the problem is solved, you can close this post
  6. #6
    You can return HttpStatusCodeResult with status code and status text

    return new HttpStatusCodeResult(500, "Unexpected error is occured");
    Status text can be retrieved from response object on the client side
    <Exception Handler="alert(response.statusText);" />
  7. #7
    +1 to Vladimir. It would be best to set up Response.StatusCode to be ensure the response will be considered as a failure one.

    Quote Originally Posted by RCN View Post
    But tell me, how the Exception listener was fired if I did not threw any exception? (I catched the exception then "return new ContentResult { Content = ex.Message };")
    A JavaScript exception occurs when Loader tries to parse a response
    Ext.encode(response);
    where the response is just a string with the error message.

    Therefore the Exception event is triggered. Certainly, it is not good.

    Setting up StatusCode to 500 causes the Loader won't parse the response at all.
  8. #8
    \o/ Thanks a lot you two.
  9. #9
    OK...

    To use the
    return new HttpStatusCodeResult(500, "Unexpected error is occured");
    I replace the return type of my method to ActionResult, to be able to return ContentResult sometimes or HttpStatusCodeResult in case of errors.

    When i alert the "response.statusText" it only comes with "Internal server error", despite the fact that i put "Unexpected error is occured" on the constructor.
  10. #10
    The ASP.Net Development server (from Visual Studio) eats the status description.
    You need to test this with a real IIS server.
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 8
    Last Post: Aug 13, 2012, 11:47 PM
  2. [CLOSED] Help on proxy exception JS error
    By cleve in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Jun 11, 2012, 9:59 AM
  3. [CLOSED] Loader double-click error
    By softmachine2011 in forum 2.x Legacy Premium Help
    Replies: 7
    Last Post: Jun 08, 2012, 11:48 AM
  4. Replies: 1
    Last Post: Feb 22, 2011, 11:25 PM
  5. [CLOSED] Show mask on listener function
    By Jurke in forum 1.x Legacy Premium Help
    Replies: 15
    Last Post: Apr 01, 2009, 8:28 AM

Tags for this Thread

Posting Permissions