Throw exception in elasticsearch from groovy

Hi everybody, is it possible to log groovy script errors and/or warning?
Or maybe throw a java exception from groovy script, to catch error?

UPDATE: Not actual any more. Problem was in logstash output plugin, not in elasticseach.