-
Notifications
You must be signed in to change notification settings - Fork 25k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inconsistent exception types thrown while parsing XContent #27147
Comments
I think that |
Thanks @javanna! So we should stick to the |
Yes let's stick to
it could be, I guess it is convenient to subclass |
Hey @liketic, I have already pushed a PR for |
Closed by #27302 |
In most cases, if the expected
START_OBJECT
is not detected, anIllegalArgumentException
is thrown :elasticsearch/core/src/main/java/org/elasticsearch/common/xcontent/XContentParserUtils.java
Lines 75 to 80 in b88dbe8
However
ObjectParser
throwsIllegalStateException
:elasticsearch/core/src/main/java/org/elasticsearch/common/xcontent/ObjectParser.java
Lines 149 to 151 in b88dbe8
When parsing
mget
two different exception types may be thrown :ParsingException
elasticsearch/core/src/main/java/org/elasticsearch/action/get/MultiGetRequest.java
Lines 323 to 330 in b88dbe8
IllegalArgumentException
elasticsearch/core/src/main/java/org/elasticsearch/action/get/MultiGetRequest.java
Lines 364 to 366 in b88dbe8
while
RepositoryData
consistently throwsElasticsearchParseException
:elasticsearch/core/src/main/java/org/elasticsearch/repositories/RepositoryData.java
Line 487 in b88dbe8
I think that it would be much cleaner if only one exception type is used (at least from now on).
For example what exception type should be thrown when a stricter validation of query field names is introduced (#26013). A different one per request (based on the exception thrown till now in the request)? Or an exception of type X?
Or maybe some of the exception types should be changed? For example can
IllegalStateException
be replaced byIllegalArgumentException
?The text was updated successfully, but these errors were encountered: