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.
I agree on logging, and I think we should enumerate the failures that this can have (like sandbox exceptions), I'll work on adding this.