Open GoogleCodeExporter opened 9 years ago
A one liner fix would be the following code added to the top of the thrown
method.
def realException = exception instanceof UndeclaredThrowableException ?
exception.undeclaredThrowable : exception;
...
Original comment by ota...@otatop.com
on 11 Feb 2013 at 5:15
The problem stems from the fact that you are throwing a checked exception from
a method that doesn't declare one. We should probably allow that for a
GroovyMock() (because Groovy doesn't have checked exceptions), but I'm unsure
if we should allow the same for a Mock().
Original comment by pnied...@gmail.com
on 21 Feb 2013 at 5:38
From what I've found on the Internets about UndeclaredThrowableException, this
is actually Java7 doing the wrapping, and it happens when a dynamic proxy
(which is what Mocks and Closures are) throws a checked exception that isn't
declared on the method being proxied.
Catching and unwrapping so that the Throws clause works correctly is on'y 1/2
of the battle.
Original comment by cdes...@gmail.com
on 27 Jan 2015 at 4:27
Original issue reported on code.google.com by
ota...@otatop.com
on 11 Feb 2013 at 4:37