@Override public String getMessage() { return super.getMessage() + " for uri: " + notFoundUri; } }
public ErrorInfo(WebApplicationException exception) { this.message = exception.getMessage(); this.status = exception.getResponse().getStatus(); }
@Override public Response toResponse(WebApplicationException e) { final ApiError apiError = ApiError.create(e.getMessage()); return Response.fromResponse(e.getResponse()) .type(MediaType.APPLICATION_JSON_TYPE) .entity(apiError).build(); } }
@Override public Response toResponse(WebApplicationException exception) { // get the message and ensure it is not blank String message = exception.getMessage(); if (message == null) { message = StringUtils.EMPTY; } // format the message if (message.contains(EXCEPTION_SEPARATOR)) { message = StringUtils.substringAfter(message, EXCEPTION_SEPARATOR); } // get the response final Response response = exception.getResponse(); // log the error logger.info(String.format("%s. Returning %s response.", exception, response.getStatus())); if (logger.isDebugEnabled()) { logger.debug(StringUtils.EMPTY, exception); } // generate the response return Response.status(response.getStatus()).entity(message).type("text/plain").build(); }
private Response handlerWebApplicationException(WebApplicationException throwable) { WebApplicationException ex = throwable; CommonResultView<?> resultView = CommonResultView.fail(ex.getResponse().getStatus() , ex.getResponse().getStatus(), ex.getMessage(), null); log.error("[WebApplicationException] {} - {}, [uri]{}", resultView.getStatus() , resultView.getMessage(), uriInfo.getPath()); return Response.status(resultView.getStatus()) .entity(resultView) .type(MediaType.APPLICATION_JSON).build(); }
public FormValidation doTestConnection(@QueryParameter String url, @QueryParameter String apiTokenId, @QueryParameter String clientBuilderId, @QueryParameter boolean ignoreCertificateErrors, @QueryParameter int connectionTimeout, @QueryParameter int readTimeout) { try { new GitLabConnection("", url, apiTokenId, clientBuilderId, ignoreCertificateErrors, connectionTimeout, readTimeout).getClient().getCurrentUser(); return FormValidation.ok(Messages.connection_success()); } catch (WebApplicationException e) { return FormValidation.error(Messages.connection_error(e.getMessage())); } catch (ProcessingException e) { return FormValidation.error(Messages.connection_error(e.getCause().getMessage())); } }
LOGGER.log(Level.WARNING, "Failed to communicate with gitlab server to determine project id: " + e.getMessage(), e);
@Override public String getMessage() { return super.getMessage() + " for uri: " + notFoundUri; } }
private static String getReasonFromServer(WebApplicationException e) { if (MediaType.APPLICATION_JSON.equals(e.getResponse().getHeaderString("Content-Type"))) { try { return e.getResponse().readEntity(ErrorData.class).reason; } catch (Exception ex) { // could not parse output to ErrorData class return e.getMessage(); } } return e.getMessage(); }
@Override public Response toResponse(WebApplicationException exception) { return Response .status(exception.getResponse().getStatus()) .type(MediaType.APPLICATION_JSON_TYPE) .entity(new ErrorDescription(exception.getMessage(), ErrorCode.OTHER)) .build(); } }
protected String buildErrorMessage(Response r, WebApplicationException ex) { StringBuilder sb = new StringBuilder(); sb.append(ERROR_MESSAGE_START).append(r.getStatus()); Throwable cause = ex.getCause(); String message = cause == null ? ex.getMessage() : cause.getMessage(); if (message == null && cause != null) { message = "exception cause class: " + cause.getClass().getName(); } if (message != null) { sb.append(", message: ").append(message); } return sb.toString(); }
public Builder add(WebApplicationException exception) { if (exception == null) return this; if (logger != null) logger.log(Level.WARNING, exception, exception::getMessage); if (exceptions == null) exceptions = new HashSet<>(); exceptions.add(exception); message(exception.getMessage()); return this; }
@Override public Response toResponse(WebApplicationException ex) { Response r = ex.getResponse(); if (r == null) { r = Response.serverError().build(); } if (this.logError(ex, r)) { WebExceptionMapper.LOGGER.warn(ex.getMessage(), ex); } return r; }
@Override public Response toResponse(WebApplicationException e) { final ApiError apiError = new ApiError(e.getMessage()); return Response.fromResponse(e.getResponse()).type(MediaType.APPLICATION_JSON_TYPE).entity(apiError).build(); } }
public Result getResult(WebTarget target) { try { return new CountResult(parse(target.path(Joiner.on(",").join(indexes)).path(Joiner.on(",").join(types)).path("_count").request().header(CONTENT_TYPE, APPLICATION_JSON).buildGet().invoke(String.class)).get("count").getAsLong()); } catch (WebApplicationException e) { return new FailureResult(e.getResponse().getStatus(), e.getMessage()); } } }
public Result getResult(WebTarget target) { try { return new JsonResult(target.path(Joiner.on(",").join(indexes)).path("_search_shards").request().header(CONTENT_TYPE, APPLICATION_JSON).buildGet().invoke(byte[].class)); } catch (WebApplicationException e) { return new FailureResult(e.getResponse().getStatus(), e.getMessage()); } } }
@Override public Object handleError(final WebApplicationException cause) { Throwable unWrapException = ExceptionHelper.unwrapException(cause); if (unWrapException instanceof RestOperationException) { int customHttpStatus = ((RestOperationException) unWrapException).getStatus(); return WebException.newException(cause.getMessage(), cause, customHttpStatus); } return WebException.newException(cause.getMessage(), unWrapException); }
@Override public Result getResult(WebTarget target) { try { return new JsonResult(target.path("_nodes").request().header(CONTENT_TYPE, APPLICATION_JSON).buildGet().invoke(byte[].class)); } catch (WebApplicationException e) { return new FailureResult(e.getResponse().getStatus(), e.getMessage()); } } }
@Override public Result getResult(WebTarget target) { try { return new JsonResult(target.path("_alias").path(alias).request().header("Accept", APPLICATION_JSON).header("content-type", APPLICATION_JSON).buildGet().invoke(byte[].class)); } catch (WebApplicationException e) { return new FailureResult(e.getResponse().getStatus(), e.getMessage()); } } }
public Result getResult(WebTarget target) { try { return new JsonResult(target.path("_cluster/health").request().header(CONTENT_TYPE, APPLICATION_JSON).buildGet().invoke(byte[].class)); } catch (WebApplicationException e) { return new FailureResult(e.getResponse().getStatus(), e.getMessage()); } } }