Open robfletcher opened 8 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;
...
Reported by otatop@otatop.com
on 2013-02-11 17:15:17
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().
Reported by pniederw
on 2013-02-21 17:38:49
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.
Reported by cdeszaq
on 2015-01-27 16:27:31
Originally reported on Google Code with ID 298
Reported by
otatop@otatop.com
on 2013-02-11 16:37:19