Announcement Announcement Module
Collapse
No announcement yet.
Exception handling through remote services. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Exception handling through remote services.

    Hi folks,

    I didn't see where this had been discussed before, so please forgive me if this is a duplicate.

    I would like to be able to elegantly handle exceptions across the HttpInvoker remoting interface. After an exhaustive search, I decided to wrap the exceptions that occur on the server side up in a serializable object and make this wrapper object the universal return value for all of my service methods. On the client side, I've created proxies that unwrap the object and either re-throw the appropriate exception or return the value that would have normally been expected. The problem is that this just feels very clunky and it's not very elegant for creating lots of services.

    Has anyone else found a good way to handle this problem?

    Thanks,
    Dave

  • #2
    What exactly is the problem? Why do you need to wrap the exceptions?

    I decided to wrap the exceptions that occur on the server side up in a serializable object and make this wrapper object the universal return value for all of my service methods
    Spring does this for you automatically. Have a look at RemoteInvocationResult and RemoteInvocationBasedExporter#invokeAndCreateResul t()

    Ollie

    Comment


    • #3
      Thanks for the heads-up. This is the first time that I've seen any evidence that Spring will pass the server-thrown exception through to the client in some fashion. None of the books I have and none of the examples that I've seen appear to take advantage of this.

      It appears from looking at the RemoteInvocationBasedExporter.invokeAndCreateResul t() method that it might throw an InvocationTargetException in my case where my application may throw some unhandled exception during the service execution. I just need to make sure that the information in that exception is something useful to the client.

      Thanks again,
      Dave

      Comment


      • #4
        Thanks for the heads-up.
        No worries. It's always a good idea to try something out rather than just assuming that it doesn't work especially with Spring where there's lots of functionality not all of which is documented.

        It appears from looking at the RemoteInvocationBasedExporter.invokeAndCreateResul t() method that it might throw an InvocationTargetException in my case where my application may throw some unhandled exception during the service execution.
        No. It will throw the same exception that was throw on the server.

        Ollie

        Comment

        Working...
        X