e public class DomainEXception extends Exception Public class InsufficientFunds Exception extends . Exception public class SystemEXception extends Exception
public class DomainException extends Exception { ... } Public class InsufficientFundsException extends …Exception { ... } public class SystemException extends Exception { ... }
public float withdrawFunds (float amount e throws InsufficientFunds Exception, SystemException Domain code that could generate various errors both technical and domain catch(Domain Exception ex throw ex catch(Exception ex) throw new SystemException(ex)
public float withdrawFunds(float amount) throws InsufficientFundsException, SystemException { try { // Domain code that could generate various errors // both technical and domain } catch (DomainException ex) { throw ex; } catch (Exception ex) { throw new SystemException(ex); } }
Error Handling patterns Big Outer Try Block Hide Technical Detail from Users Log at Distribution Log Unexpected Boundary Errors Unique Error Split Domain and Make Exceptions Identifier Technical errors Exceptional
Error Handling Patterns
Big outer Try Block e Errors will propagate right to the edge of the system and will appear to crash the application if not handled at that point e Users are mostly on remote sites and will not do much to report errors
Big Outer Try Block Errors will propagate right to the edge of the system and will appear to “crash” the application if not handled at that point. Users are mostly on remote sites and will not do much to report errors
e Solution e Implement a Big Outer Try Block at the "edge" of the system to catch and handle errors that cannot be handled by other tiers of the system. The error handling in the block can report errors in a consistent way at a level of detail appropriate to the user constituency
Solution Implement a Big Outer Try Block at the “edge” of the system to catch and handle errors that cannot be handled by other tiers of the system. The error handling in the block can report errors in a consistent way at a level of detail appropriate to the user constituency