diff options
author | Endi S. Dewata <edewata@redhat.com> | 2015-01-20 09:25:32 -0500 |
---|---|---|
committer | Endi S. Dewata <edewata@redhat.com> | 2015-01-21 15:35:37 -0500 |
commit | 802f7471d5ee65e3c4d99b528bb6d8526c277185 (patch) | |
tree | 02dd03d41e301499b0b28fbd0af948f253bac03d /base/common/src/com/netscape/certsrv/base | |
parent | deb188bffd38f82396c47411381a875020ca748b (diff) | |
download | pki-802f7471d5ee65e3c4d99b528bb6d8526c277185.tar.gz pki-802f7471d5ee65e3c4d99b528bb6d8526c277185.tar.xz pki-802f7471d5ee65e3c4d99b528bb6d8526c277185.zip |
Added support for exception chains in EBaseException.
The EBaseException has been modified to provide constructors that
can be used to chain the cause of the exception. This way the root
cause of the exception can be traced back to help troubleshooting.
Some codes have been modified to utilize the proper exception
chaining as examples.
https://fedorahosted.org/pki/ticket/915
Diffstat (limited to 'base/common/src/com/netscape/certsrv/base')
-rw-r--r-- | base/common/src/com/netscape/certsrv/base/EBaseException.java | 60 |
1 files changed, 46 insertions, 14 deletions
diff --git a/base/common/src/com/netscape/certsrv/base/EBaseException.java b/base/common/src/com/netscape/certsrv/base/EBaseException.java index 140a6acbc..78d9a6d2d 100644 --- a/base/common/src/com/netscape/certsrv/base/EBaseException.java +++ b/base/common/src/com/netscape/certsrv/base/EBaseException.java @@ -63,25 +63,24 @@ public class EBaseException extends Exception { } /** - * Constructs an instance of the exception given the resource key and - * a exception parameter. + * Constructs an instance of this exception given the resource key and + * the cause exception. * - * <PRE> - * try { - * ... - * } catch (IOExeption e) { - * throw new EBaseException(BaseResources.INTERNAL_ERROR_1, e); - * } - * </PRE> - * <P> + * <pre> + * try { + * ... + * } catch (IOExeption e) { + * throw new EBaseException(BaseResources.INTERNAL_ERROR_1, e); + * } + * </pre> * * @param msgFormat The resource key - * @param param The parameter as an exception + * @param cause The cause exception */ - public EBaseException(String msgFormat, Exception param) { - super(msgFormat); + public EBaseException(String msgFormat, Exception cause) { + super(msgFormat, cause); mParams = new Exception[1]; - mParams[0] = param; + mParams[0] = cause; } /** @@ -98,6 +97,39 @@ public class EBaseException extends Exception { } /** + * Constructs an instance of this exception given the resource key, + * an array of parameters, and the cause exception. + * <P> + * + * @param msgFormat The resource key + * @param params Array of params + * @param cause The cause exception + */ + public EBaseException(String msgFormat, Object params[], Exception cause) { + super(msgFormat, cause); + mParams = params; + } + + /** + * Constructs an instance of this exception given the cause exception. + * + * <pre> + * try { + * ... + * } catch (IOExeption e) { + * throw new EBaseException(e); + * } + * </pre> + * + * @param cause The cause exception + */ + public EBaseException(Exception cause) { + super(cause.getMessage() == null ? cause.getClass().getName() : cause.getMessage(), cause); + mParams = new Exception[1]; + mParams[0] = cause; + } + + /** * Returns the list of parameters. * <P> * |