summaryrefslogtreecommitdiff
path: root/lang/java/src/com/sleepycat/util/RuntimeExceptionWrapper.java
diff options
context:
space:
mode:
authorLorry <lorry@roadtrain.codethink.co.uk>2012-07-20 20:00:05 +0100
committerLorry <lorry@roadtrain.codethink.co.uk>2012-07-20 20:00:05 +0100
commit3ef782d3745ea8f25a3151561a3cfb882190210e (patch)
tree86b9c2f5fde051dd0bced99b3fc9f5a3ba08db69 /lang/java/src/com/sleepycat/util/RuntimeExceptionWrapper.java
downloadberkeleydb-3ef782d3745ea8f25a3151561a3cfb882190210e.tar.gz
Tarball conversion
Diffstat (limited to 'lang/java/src/com/sleepycat/util/RuntimeExceptionWrapper.java')
-rw-r--r--lang/java/src/com/sleepycat/util/RuntimeExceptionWrapper.java47
1 files changed, 47 insertions, 0 deletions
diff --git a/lang/java/src/com/sleepycat/util/RuntimeExceptionWrapper.java b/lang/java/src/com/sleepycat/util/RuntimeExceptionWrapper.java
new file mode 100644
index 00000000..27078728
--- /dev/null
+++ b/lang/java/src/com/sleepycat/util/RuntimeExceptionWrapper.java
@@ -0,0 +1,47 @@
+/*-
+ * See the file LICENSE for redistribution information.
+ *
+ * Copyright (c) 2000, 2012 Oracle and/or its affiliates. All rights reserved.
+ *
+ */
+
+package com.sleepycat.util;
+
+/**
+ * A RuntimeException that can contain nested exceptions.
+ *
+ * @author Mark Hayes
+ */
+public class RuntimeExceptionWrapper extends RuntimeException
+ implements ExceptionWrapper {
+
+ /**
+ * Wraps the given exception if it is not a {@code RuntimeException}.
+ *
+ * @param e any exception.
+ *
+ * @return {@code e} if it is a {@code RuntimeException}, otherwise a
+ * {@code RuntimeExceptionWrapper} for {@code e}.
+ */
+ public static RuntimeException wrapIfNeeded(Throwable e) {
+ if (e instanceof RuntimeException) {
+ return (RuntimeException) e;
+ }
+ return new RuntimeExceptionWrapper(e);
+ }
+
+ private static final long serialVersionUID = 1106961350L;
+
+ public RuntimeExceptionWrapper(Throwable e) {
+
+ super(e);
+ }
+
+ /**
+ * @deprecated replaced by {@link #getCause}.
+ */
+ public Throwable getDetail() {
+
+ return getCause();
+ }
+}