/** * Generate a {@link ElasticsearchException} from a {@link XContentParser}. This does not * return the original exception type (ie NodeClosedException for example) but just wraps * the type, the reason and the cause of the exception. It also recursively parses the * tree structure of the cause, returning it as a tree structure of {@link ElasticsearchException} * instances. */ public static ElasticsearchException fromXContent(XContentParser parser) throws IOException { XContentParser.Token token = parser.nextToken(); ensureExpectedToken(XContentParser.Token.FIELD_NAME, token, parser::getTokenLocation); return innerFromXContent(parser, false); }
/** * Parses the output of {@link #generateFailureXContent(XContentBuilder, Params, Exception, boolean)} */ public static ElasticsearchException failureFromXContent(XContentParser parser) throws IOException { XContentParser.Token token = parser.currentToken(); ensureFieldName(parser, token, ERROR); token = parser.nextToken(); if (token.isValue()) { return new ElasticsearchException(buildMessage("exception", parser.text(), null)); } ensureExpectedToken(XContentParser.Token.START_OBJECT, token, parser::getTokenLocation); token = parser.nextToken(); // Root causes are parsed in the innerFromXContent() and are added as suppressed exceptions. return innerFromXContent(parser, true); }
); } else if (EXPECTED_EXCEPTION_FIELDS.contains(fieldName)){ return new StatusOrException(ElasticsearchException.innerFromXContent(parser, false)); } else {
/** * Generate a {@link ElasticsearchException} from a {@link XContentParser}. This does not * return the original exception type (ie NodeClosedException for example) but just wraps * the type, the reason and the cause of the exception. It also recursively parses the * tree structure of the cause, returning it as a tree structure of {@link ElasticsearchException} * instances. */ public static ElasticsearchException fromXContent(XContentParser parser) throws IOException { XContentParser.Token token = parser.nextToken(); ensureExpectedToken(XContentParser.Token.FIELD_NAME, token, parser::getTokenLocation); return innerFromXContent(parser, false); }
/** * Generate a {@link ElasticsearchException} from a {@link XContentParser}. This does not * return the original exception type (ie NodeClosedException for example) but just wraps * the type, the reason and the cause of the exception. It also recursively parses the * tree structure of the cause, returning it as a tree structure of {@link ElasticsearchException} * instances. */ public static ElasticsearchException fromXContent(XContentParser parser) throws IOException { XContentParser.Token token = parser.nextToken(); ensureExpectedToken(XContentParser.Token.FIELD_NAME, token, parser::getTokenLocation); return innerFromXContent(parser, false); }
/** * Generate a {@link ElasticsearchException} from a {@link XContentParser}. This does not * return the original exception type (ie NodeClosedException for example) but just wraps * the type, the reason and the cause of the exception. It also recursively parses the * tree structure of the cause, returning it as a tree structure of {@link ElasticsearchException} * instances. */ public static ElasticsearchException fromXContent(XContentParser parser) throws IOException { XContentParser.Token token = parser.nextToken(); ensureExpectedToken(XContentParser.Token.FIELD_NAME, token, parser::getTokenLocation); return innerFromXContent(parser, false); }
/** * Parses the output of {@link #generateFailureXContent(XContentBuilder, Params, Exception, boolean)} */ public static ElasticsearchException failureFromXContent(XContentParser parser) throws IOException { XContentParser.Token token = parser.currentToken(); ensureFieldName(parser, token, ERROR); token = parser.nextToken(); if (token.isValue()) { return new ElasticsearchException(buildMessage("exception", parser.text(), null)); } ensureExpectedToken(XContentParser.Token.START_OBJECT, token, parser::getTokenLocation); token = parser.nextToken(); // Root causes are parsed in the innerFromXContent() and are added as suppressed exceptions. return innerFromXContent(parser, true); }
/** * Parses the output of {@link #generateFailureXContent(XContentBuilder, Params, Exception, boolean)} */ public static ElasticsearchException failureFromXContent(XContentParser parser) throws IOException { XContentParser.Token token = parser.currentToken(); ensureFieldName(parser, token, ERROR); token = parser.nextToken(); if (token.isValue()) { return new ElasticsearchException(buildMessage("exception", parser.text(), null)); } ensureExpectedToken(XContentParser.Token.START_OBJECT, token, parser::getTokenLocation); token = parser.nextToken(); // Root causes are parsed in the innerFromXContent() and are added as suppressed exceptions. return innerFromXContent(parser, true); }
/** * Parses the output of {@link #generateFailureXContent(XContentBuilder, Params, Exception, boolean)} */ public static ElasticsearchException failureFromXContent(XContentParser parser) throws IOException { XContentParser.Token token = parser.currentToken(); ensureFieldName(parser, token, ERROR); token = parser.nextToken(); if (token.isValue()) { return new ElasticsearchException(buildMessage("exception", parser.text(), null)); } ensureExpectedToken(XContentParser.Token.START_OBJECT, token, parser::getTokenLocation); token = parser.nextToken(); // Root causes are parsed in the innerFromXContent() and are added as suppressed exceptions. return innerFromXContent(parser, true); }
); } else if (EXPECTED_EXCEPTION_FIELDS.contains(fieldName)){ return new StatusOrException(ElasticsearchException.innerFromXContent(parser, false)); } else {
} else if (token == Token.START_OBJECT) { parser.nextToken(); exception = ElasticsearchException.innerFromXContent(parser, true); } else if (token == Token.START_ARRAY) { parser.skipChildren();
} else if (token == Token.START_OBJECT) { parser.nextToken(); exception = ElasticsearchException.innerFromXContent(parser, true); } else if (token == Token.START_ARRAY) { parser.skipChildren();