Is there a way to handle unexpected exceptions in Spock? My use-case is to make test failures where exceptions are thrown better human-readable. E.g. when a test fails with an HttpClientErrorException, I would like to have the status code and the body in the printed test output.
e.g.
when:
restTemplate.getForObject(url, String)
then:
noExceptionThrown()
Now the getForObject() call throws an HttpClientErrorException I want an output like this:
Expected no exception to be thrown, but got 'HttpClientErrorException'
Status-Code: 400
Body: '{"error": "parameter foo missing"}'