Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openbis
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sispub
openbis
Commits
2d6447d1
Commit
2d6447d1
authored
17 years ago
by
ribeaudc
Browse files
Options
Downloads
Patches
Plain Diff
add: - 'CheckedExceptionTunnel.unwrapIfNecessary'.
SVN: 4456
parent
371501ab
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
common/source/java/ch/systemsx/cisd/common/exceptions/CheckedExceptionTunnel.java
+22
-4
22 additions, 4 deletions
...stemsx/cisd/common/exceptions/CheckedExceptionTunnel.java
with
22 additions
and
4 deletions
common/source/java/ch/systemsx/cisd/common/exceptions/CheckedExceptionTunnel.java
+
22
−
4
View file @
2d6447d1
...
@@ -31,7 +31,7 @@ public final class CheckedExceptionTunnel extends RuntimeException
...
@@ -31,7 +31,7 @@ public final class CheckedExceptionTunnel extends RuntimeException
*
*
* @param checkedException The checked exception to tunnel.
* @param checkedException The checked exception to tunnel.
*/
*/
public
CheckedExceptionTunnel
(
Exception
checkedException
)
public
CheckedExceptionTunnel
(
final
Exception
checkedException
)
{
{
super
(
checkedException
);
super
(
checkedException
);
...
@@ -40,14 +40,15 @@ public final class CheckedExceptionTunnel extends RuntimeException
...
@@ -40,14 +40,15 @@ public final class CheckedExceptionTunnel extends RuntimeException
/**
/**
* Returns a {@link RuntimeException} from an <var>exception</var>. If <var>exception</var> is already a
* Returns a {@link RuntimeException} from an <var>exception</var>. If <var>exception</var> is already a
* {@link RuntimeException}, itself is returned, otherwise a {@link CheckedExceptionTunnel} with
* {@link RuntimeException}, itself is returned, otherwise a {@link CheckedExceptionTunnel} with
<var>exception</var>
*
<var>exception</var>
as checked exception argument.
* as checked exception argument.
*
*
* @param exception The exception to represent by the return value.
* @param exception The exception to represent by the return value.
* @return A {@link RuntimeException} representing the <var>exception</var>.
* @return A {@link RuntimeException} representing the <var>exception</var>.
*/
*/
public
static
RuntimeException
wrapIfNecessary
(
Exception
exception
)
public
final
static
RuntimeException
wrapIfNecessary
(
final
Exception
exception
)
{
{
assert
exception
!=
null
:
"Unspecified exception."
;
if
(
exception
instanceof
RuntimeException
)
if
(
exception
instanceof
RuntimeException
)
{
{
return
(
RuntimeException
)
exception
;
return
(
RuntimeException
)
exception
;
...
@@ -57,4 +58,21 @@ public final class CheckedExceptionTunnel extends RuntimeException
...
@@ -57,4 +58,21 @@ public final class CheckedExceptionTunnel extends RuntimeException
}
}
}
}
/**
* Returns the original exception before being wrapped, if the exception has been wrapped, or <var>exception</var>
* otherwise.
*/
public
final
static
Exception
unwrapIfNecessary
(
final
RuntimeException
exception
)
{
assert
exception
!=
null
:
"Unspecified exception."
;
if
(
exception
instanceof
CheckedExceptionTunnel
)
{
// We are sur that the wrapped exception is an 'Exception'.
return
(
Exception
)
exception
.
getCause
();
}
else
{
return
exception
;
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment