Skip to content

Commit

Permalink
WrappedCheckedException.wrap(String message, Throwable t) now ensures…
Browse files Browse the repository at this point in the history
… that RuntimeExceptions contain the specified message; otherwise, they are wrapped.
  • Loading branch information
cowwoc committed Sep 13, 2024
1 parent b2db051 commit ef4f55a
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public static RuntimeException wrap(Throwable t)
}

/**
* Wraps an exception, unless it is a {@code RuntimeException}.
* Wraps an exception, unless it is a {@code RuntimeException} with the specified {@code message}.
*
* @param message the detail message of the WrappedCheckedException
* @param t the exception to wrap
Expand All @@ -103,7 +103,7 @@ public static RuntimeException wrap(Throwable t)
*/
public static RuntimeException wrap(String message, Throwable t)
{
if (t instanceof RuntimeException)
if (t instanceof RuntimeException && t.getMessage().equals(message))
return (RuntimeException) t;
if (t instanceof ExecutionException)
return wrap(message, t.getCause());
Expand Down

0 comments on commit ef4f55a

Please sign in to comment.