3 Replies Latest reply on Mar 9, 2015 1:01 PM by csa

    Errai-Bus and client side error handling

    timeu

      I am using Errai-Bus 3.1.2.Final in a GWT applicaiton and I have troubles getting the client side error handling to work.

       

      Here is the setup:


      I am trying to send a Message to the backend:

       

      Date date = new Date();

      MessageBuilder.createMessage()

           .toSubject("Hearbeat")

           .signalling()

           .withValue(date)

           .errorsHandledBy(new ErrorCallback<Message>() {

                     @Override
                      public boolean error(Message o, Throwable throwable) {

                         GWT.log("Error");
                         return true;
                    }

           })

        .sendNowWith(dispatcher);

       

       

      On the backend I have a MessageCallback and for testing purposes I throw a custom SessionTimeOutException (which is in the -shared package that can be accessed by both the GWT client and backend):

       

       

       

      @Service
      public class Hearbeat implements MessageCallback {

       

         @Override
         public void callback(Message message) {

               throw new SessionTimeOutException();

         }

      }

       

      public class SessionTimeOutException extends RuntimeException {

      }

       

      I added this lien to the ErraiApp.properties:

       

      errai.marshalling.serializableTypes=xxx.shared.exceptions.SessionTimeOutException

       

       

      However my custom ErrorCallback is never called. Instead my global uncaughtExceptionHandler is called with a JavascriptException (""Cannot read property 'stringValue_3_g$' of null"")

       

      So there are two issues here:

       

      1.) My custom ErrorCallback is not called

      2.) My custom Exception does not get sent to the client.

       

      I would be thankful for any advice.

       

      EDIT:

      The exception ""Cannot read property 'stringValue_3_g$' of null"" is due to the fact that I create an Exception without a message.

      This seems to be a bug in the ErraiProtcolEnvelopeMarshaller.java.

      This line will throw a null pointer exception when there is no message

      https://github.com/errai/errai/blob/master/errai-marshalling/src/main/java/org/jboss/errai/marshalling/client/marshallers/ErraiProtocolEnvelopeMarshaller.java#L55


      After changing this to a non null message, instead of a JavascriptException a normal Exception is thrown


      EDIT2:

      After moving the ErraiApp.properties file to the client side package, my custom exception is properly sent to the client.