1 Reply Latest reply on Jun 18, 2008 7:08 AM by levancho

    exception handling in flex

    smscentral
      hi all,

      i am using httpservice to request a method call in the servlet.
      the method in servlet throws exception with some message
      say throws new IncorrectParameterException("incorrect parameters passed"); in my servlet.

      how do i get this message in flex.

      I tried using asynctoken = httpservice.send();

      and added a responder with fault event and i get the alert message with the properties of error message..but not the actual message..and not even the exception class type.

      i just get the bubble,cancellable and the url of my servlet in the alert with alert.show(event.rootcause)

      so,how do i get the message "incorrect parameter passed" in the flex so as to give an appropriate error message to the end user..

      thanks in advace
      chandana
        • 1. Re: exception handling in flex
          levancho Level 3
          htpService communications are exclusively via xml,
          if you had used RemoteObject (blazeDS) it handles throwable objects very nicely, but with httpService you have to return a error xml, you xan to something lik ethis in servlet

          try {
          code that throws eception etc ... lalala
          } catch (Exception e) {

          //generate error xml, and flush it back via response,

          out.println("<response>"+e.getMessage() +"</response>");
          etc ...
          }

          than you can read that error in httpService, as regular response,
          I am not sure if you can force this message to go throuhg faultREsult though,