Wrap groovy script exceptions in a serializable Exception object

Fixes #6598

It prevents ES from trying to serialize the default Groovy exceptions, which want to carry over a lot of state that doesn't  serialize properly.
What do you think about catching AssertionError directly? I am worried that catching Throwable means catching `OutOfMemoryError` and swallowing the exception (which we have to do for the groovy exceptions).