Java Code Examples for org.elasticsearch.rest.RestStatus#BAD_REQUEST
The following examples show how to use
org.elasticsearch.rest.RestStatus#BAD_REQUEST .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TranslogRecoveryPerformer.java From Elasticsearch with Apache License 2.0 | 6 votes |
public int recoveryFromSnapshot(Engine engine, Translog.Snapshot snapshot) throws IOException { Translog.Operation operation; int opsRecovered = 0; while ((operation = snapshot.next()) != null) { try { performRecoveryOperation(engine, operation, true); opsRecovered++; } catch (ElasticsearchException e) { if (e.status() == RestStatus.BAD_REQUEST) { // mainly for MapperParsingException and Failure to detect xcontent logger.info("ignoring recovery of a corrupt translog entry", e); } else { throw e; } } } return opsRecovered; }
Example 2
Source File: AuthService.java From elasticsearch-auth with Apache License 2.0 | 5 votes |
private Authenticator getAuthenticator(final String authenticatorName) { final Authenticator authenticator = authenticatorMap .get(authenticatorName); if (authenticator == null) { throw new AuthException(RestStatus.BAD_REQUEST, "Unknown authenticator: " + authenticatorName); } return authenticator; }
Example 3
Source File: ExceptionsHelper.java From crate with Apache License 2.0 | 5 votes |
public static RestStatus status(Throwable t) { if (t != null) { if (t instanceof ElasticsearchException) { return ((ElasticsearchException) t).status(); } else if (t instanceof IllegalArgumentException) { return RestStatus.BAD_REQUEST; } else if (t instanceof EsRejectedExecutionException) { return RestStatus.TOO_MANY_REQUESTS; } } return RestStatus.INTERNAL_SERVER_ERROR; }
Example 4
Source File: ExceptionsHelper.java From Elasticsearch with Apache License 2.0 | 5 votes |
public static RestStatus status(Throwable t) { if (t != null) { if (t instanceof ElasticsearchException) { return ((ElasticsearchException) t).status(); } else if (t instanceof IllegalArgumentException) { return RestStatus.BAD_REQUEST; } } return RestStatus.INTERNAL_SERVER_ERROR; }
Example 5
Source File: SearchParseException.java From Elasticsearch with Apache License 2.0 | 4 votes |
@Override public RestStatus status() { return RestStatus.BAD_REQUEST; }
Example 6
Source File: InvalidSnapshotNameException.java From Elasticsearch with Apache License 2.0 | 4 votes |
@Override public RestStatus status() { return RestStatus.BAD_REQUEST; }
Example 7
Source File: MapperParsingException.java From Elasticsearch with Apache License 2.0 | 4 votes |
@Override public RestStatus status() { return RestStatus.BAD_REQUEST; }
Example 8
Source File: StrictDynamicMappingException.java From Elasticsearch with Apache License 2.0 | 4 votes |
@Override public RestStatus status() { return RestStatus.BAD_REQUEST; }
Example 9
Source File: InvalidTypeNameException.java From crate with Apache License 2.0 | 4 votes |
@Override public RestStatus status() { return RestStatus.BAD_REQUEST; }
Example 10
Source File: MapperParsingException.java From crate with Apache License 2.0 | 4 votes |
@Override public RestStatus status() { return RestStatus.BAD_REQUEST; }
Example 11
Source File: TransportBaseSQLAction.java From Elasticsearch with Apache License 2.0 | 4 votes |
/** * Create a {@link io.crate.action.sql.SQLActionException} out of a {@link java.lang.Throwable}. * If concrete {@link org.elasticsearch.ElasticsearchException} is found, first transform it * to a {@link io.crate.exceptions.CrateException} */ private SQLActionException buildSQLActionException(Throwable e) { logger.error("errors while processing sql", e); if (e instanceof SQLActionException) { return (SQLActionException) e; } e = esToCrateException(e); int errorCode = 5000; RestStatus restStatus = RestStatus.INTERNAL_SERVER_ERROR; if (e instanceof CrateException) { CrateException crateException = (CrateException) e; if (e instanceof ValidationException) { errorCode = 4000 + crateException.errorCode(); restStatus = RestStatus.BAD_REQUEST; } else if (e instanceof NoPermissionException) { errorCode = 4000 + crateException.errorCode(); restStatus = RestStatus.UNAUTHORIZED; e.setStackTrace(new StackTraceElement[0]); } else if (e instanceof ForbiddenException) { errorCode = 4030 + crateException.errorCode(); restStatus = RestStatus.FORBIDDEN; } else if (e instanceof ResourceUnknownException) { errorCode = 4040 + crateException.errorCode(); restStatus = RestStatus.NOT_FOUND; } else if (e instanceof ConflictException) { errorCode = 4090 + crateException.errorCode(); restStatus = RestStatus.CONFLICT; } else if (e instanceof UnhandledServerException) { errorCode = 5000 + crateException.errorCode(); } } else if (e instanceof ParsingException) { errorCode = 4000; restStatus = RestStatus.BAD_REQUEST; } else if (e instanceof MapperParsingException) { errorCode = 4000; restStatus = RestStatus.BAD_REQUEST; } String message = e.getMessage(); if (message == null) { if (e instanceof CrateException && e.getCause() != null) { e = e.getCause(); // use cause because it contains a more meaningful error in most cases } StackTraceElement[] stackTraceElements = e.getStackTrace(); if (stackTraceElements.length > 0) { message = String.format(Locale.ENGLISH, "%s in %s", e.getClass().getSimpleName(), stackTraceElements[0]); } else { message = "Error in " + e.getClass().getSimpleName(); } } else { message = e.getClass().getSimpleName() + ": " + message; } return new SQLActionException(message, errorCode, restStatus, e.getStackTrace()); }
Example 12
Source File: IndexClosedException.java From crate with Apache License 2.0 | 4 votes |
@Override public RestStatus status() { return RestStatus.BAD_REQUEST; }
Example 13
Source File: ElasticsearchParseException.java From crate with Apache License 2.0 | 4 votes |
@Override public RestStatus status() { return RestStatus.BAD_REQUEST; }
Example 14
Source File: StrictDynamicMappingException.java From crate with Apache License 2.0 | 4 votes |
@Override public RestStatus status() { return RestStatus.BAD_REQUEST; }
Example 15
Source File: ResourceAlreadyExistsException.java From crate with Apache License 2.0 | 4 votes |
@Override public RestStatus status() { return RestStatus.BAD_REQUEST; }
Example 16
Source File: TcpTransport.java From crate with Apache License 2.0 | 4 votes |
@Override public RestStatus status() { return RestStatus.BAD_REQUEST; }
Example 17
Source File: InvalidTypeNameException.java From Elasticsearch with Apache License 2.0 | 4 votes |
@Override public RestStatus status() { return RestStatus.BAD_REQUEST; }
Example 18
Source File: InvalidIndexNameException.java From crate with Apache License 2.0 | 4 votes |
@Override public RestStatus status() { return RestStatus.BAD_REQUEST; }
Example 19
Source File: InvalidIndexTemplateException.java From Elasticsearch with Apache License 2.0 | 4 votes |
@Override public RestStatus status() { return RestStatus.BAD_REQUEST; }
Example 20
Source File: SnapshotInProgressException.java From crate with Apache License 2.0 | 4 votes |
@Override public RestStatus status() { return RestStatus.BAD_REQUEST; }