# Can I intentionally fail or throw exception in a painless script for update API?

**URL:** https://discuss.elastic.co/t/can-i-intentionally-fail-or-throw-exception-in-a-painless-script-for-update-api/232327
**Category:** Elasticsearch
**Created:** [May 12, 2020, 9:13pm UTC](https://discuss.elastic.co/t/can-i-intentionally-fail-or-throw-exception-in-a-painless-script-for-update-api/232327 "2020-05-12T21:13:53Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![duopan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/duopan/32/68090_2.png) [@duopan](https://discuss.elastic.co/u/duopan)
#### Post date: [May 12, 2020, 9:13pm UTC](https://discuss.elastic.co/t/can-i-intentionally-fail-or-throw-exception-in-a-painless-script-for-update-api/232327/1 "2020-05-12T21:13:53Z")

</div>

Hello experts,

I would like to throw exception or return error based on application logic in a painless script during update, since update API cannot have any return. But I couldn't find related info on the website yet. Could someone help me with this?

Thank you very much!

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [June 9, 2020, 9:13pm UTC](https://discuss.elastic.co/t/can-i-intentionally-fail-or-throw-exception-in-a-painless-script-for-update-api/232327/2 "2020-06-09T21:13:53Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
