Runtime components : Core components : Exceptions : Base rules for handling exceptions
  
Base rules for handling exceptions
Following are the base rules for handling exceptions in UNICOM® Digital Transformation Toolkit (UDTT™):
1 Define meaningful exception types. The defined exception types must be extended from UDTT base exception classes.
2 After you caught the exception using the try...catch clause, you can only do one of the following:
Handle the exception and trace the exception
Throw out the exception again
Otherwise, the exception information might be traced twice. So when you throw out exception in the catch clause, the exception should not be traced.
Note Do NOT use the following example to handle exceptions:
try{
  ...
}
catch (Exception e){
  if (log.doError()) log.error(“exception in XXXX method”, e);
  // Not permitted for it may cause same exception be traced duplicated.
  throw new BTTSampleException1(e);

}
3 When you catch and re-throw new exceptions, transfer the original exception instance. The whole exception object can be wrapped with a new exception as in the following example:
try{
...
}
catch (Exception e){
throw new BTTSampleException1(e) ;
// or use: throw new BTTSampleException1(“more exception information here…”, e);
// The below usage is NOT permitted for the exception stack trace information will be lost.
// throw new BTTSampleException1(e.getMessage()) ;
}
Go up to
Exceptions