Women in Technology

Hear us Roar



Article:
  Best Practices for Exception Handling
Subject:   Nested Exceptions in distributed systems
Date:   2003-11-20 18:25:55
From:   anonymous2
Hi,


You didn't mention that nested exceptions and distributed systems do not mix well.


Consider this attempt to prevent the client from needing to know about some details:


// code in an EJB somewhere...
catch (MyJmsFrameworkException e) {
logger.severe(e);
throw new RuntimeException(e)
}


In a single VM that's fine: I've isolated the client from needing to know about MyJmsFrameworkExceptions.


But in a distributed environment I've failed to do that because the client VM will try to deserialize that RuntimeException, find the nested exception, and then fail if its classloader can't find MyJmsFrameworkException.


In short: be aware that you are only sort-of hiding an exception from a client when you nest it in another exception.


Sean