# Exceptions are difficult to parse

**URL:** <https://discuss.elastic.co/t/exceptions-are-difficult-to-parse/6455>\
**Category:** Elasticsearch\
**Created:** [January 20, 2012, 8:31pm UTC](https://discuss.elastic.co/t/exceptions-are-difficult-to-parse/6455 "2012-01-20T20:31:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mark\_Waddle](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_waddle/32/2608_2.png) [@Mark\_Waddle](https://discuss.elastic.co/u/Mark_Waddle)\
**Post date:** [January 20, 2012, 8:31pm UTC](https://discuss.elastic.co/t/exceptions-are-difficult-to-parse/6455/1 "2012-01-20T20:31:08Z")

</div>

I've found that parsing exceptions from the Java client or a REST client is  
a PITA. This is especially true for search when you are getting exceptions  
from numerous shards. Does anyone have a solution to this?

Shay: Have you considered returning the exception data as JSON instead of  
serialized strings?

Mark

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [January 23, 2012, 6:40pm UTC](https://discuss.elastic.co/t/exceptions-are-difficult-to-parse/6455/2 "2012-01-23T18:40:15Z")

</div>

What are you parsing it for? Are you looking for something specific? The  
REST status code (associated with an ElasticSearchException, or returned as  
part of the HTTP response) is usually the one you need.

On Fri, Jan 20, 2012 at 10:31 PM, Mark Waddle [mark@markwaddle.com](mailto:mark@markwaddle.com) wrote:

> I've found that parsing exceptions from the Java client or a REST client  
> is a PITA. This is especially true for search when you are getting  
> exceptions from numerous shards. Does anyone have a solution to this?
> 
> Shay: Have you considered returning the exception data as JSON instead of  
> serialized strings?
> 
> Mark

---

<div class="post-metadata">

**Author:** ![Mark\_Waddle](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_waddle/32/2608_2.png) [@Mark\_Waddle](https://discuss.elastic.co/u/Mark_Waddle)\
**Post date:** [January 24, 2012, 3:21am UTC](https://discuss.elastic.co/t/exceptions-are-difficult-to-parse/6455/3 "2012-01-24T03:21:06Z")

</div>

I'm using the Java client and I'm passing a Lucene query string from the  
user to ES. In cases where the user provides an invalid query, I am trying  
to determine where the user went wrong based on the exception, but it is a  
challenge. After thinking about it some more I realize that even if the  
nested exception data from each shard was available in an object it would  
not be useful because it is usually the Lucene query parser error of "was  
expecting one of #@$)@#U$". I'm sure you know the one. For now I think I am  
going to simply notify the user that there is an error in their query and  
point them to some help.

It might still be useful however to provide the shard exceptions as objects  
instead of just a large string for other purposes though.

Mark

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [January 24, 2012, 2:22pm UTC](https://discuss.elastic.co/t/exceptions-are-difficult-to-parse/6455/4 "2012-01-24T14:22:03Z")

</div>

Yea, for your need, even if it was broken down to an "object", it would  
still be problematic because of how the parsing failure is raised and  
constructed.

On Tue, Jan 24, 2012 at 5:21 AM, Mark Waddle [mark@markwaddle.com](mailto:mark@markwaddle.com) wrote:

> I'm using the Java client and I'm passing a Lucene query string from the  
> user to ES. In cases where the user provides an invalid query, I am trying  
> to determine where the user went wrong based on the exception, but it is a  
> challenge. After thinking about it some more I realize that even if the  
> nested exception data from each shard was available in an object it would  
> not be useful because it is usually the Lucene query parser error of "was  
> expecting one of #@$)@#U$". I'm sure you know the one. For now I think I am  
> going to simply notify the user that there is an error in their query and  
> point them to some help.
> 
> It might still be useful however to provide the shard exceptions as  
> objects instead of just a large string for other purposes though.
> 
> Mark

---

<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:** [July 6, 2017, 3:41am UTC](https://discuss.elastic.co/t/exceptions-are-difficult-to-parse/6455/5 "2017-07-06T03:41:41Z")

</div>


