1 Reply Latest reply on Sep 19, 2011 10:40 AM by csa

    Catching server-side exceptions on client side?

    superfis

      Hi,

      I'm using errai 1.3.0.CR1 and communication between client and server looks like this:

       

      client code

       

      (sending message)

      MessageBuilder.createMessage().toSubject(DEPENDENTNUMBERS_SERVICE)

                                              .signalling()

                                              .with(MessageParts.ReplyTo, DEPENDENTNUMBERS_CLIENT)

                                              .with("selectedNumber", baseNumber).errorsHandledBy( new ErrorCallback( ) {

                          @Override

        (1)               public boolean error( Message message, Throwable throwable ) {

                              throwable.printStackTrace( );

                              return true;

                          }

                      } )

                                              .sendNowWith(dispatcher);

       

       

      server code

       

      (receiving message and sending response)

      @Service

      public class DependentNumbersService implements MessageCallback {

      ...

      @Override

          public void callback( Message message ) {

              throw new AuthenticationException("you are not logged in yet!");

          }

      }

       

       

      client code again

       

      (receiving message)

      erraiBus.subscribe(DEPENDENTNUMBERS_CLIENT, new MessageCallback() {

        @Override

                                    public void callback(Message message) {

                                              dependentNumbers = message.get(List.class, "subnumbers");

                                              view.showDependentNumbers(dependentNumbers);

                                    }

                          });


       

      The problem is that I can't catch exception raised on server side (AuthenticationException).

      The method bookmarked in code as (1) is not handling the exception.

       

      I saw the example RPCdemo attached to errai-1.3.0.CR1.zip file and there is an example how to catch exceptions raised on server side, but it's for RPC calls only.

       

      How can I catch server-side exceptions with using errai messages?