org.glassfish.hk2.api.MultiException Java Examples

The following examples show how to use org.glassfish.hk2.api.MultiException. 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: MultiQueryAction.java    From foxtrot with Apache License 2.0 6 votes vote down vote up
@Override
public void validateImpl(MultiQueryRequest parameter) {
    MultiQueryRequest multiQueryRequest = getParameter();
    MultiException multiException = new MultiException();
    processForSubQueries(multiQueryRequest, (action, request) -> {
        try {
            action.validateImpl(request);
        } catch (MalformedQueryException e) {
            multiException.addError(e);
        }
        return null;
    });
    if(CollectionUtils.isNotEmpty(multiException.getErrors())) {
        throw multiException;
    }

}
 
Example #2
Source File: ExceptionFilter.java    From hugegraph with Apache License 2.0 5 votes vote down vote up
@Override
public Response toResponse(Throwable exception) {
    if (exception instanceof MultiException &&
        ((MultiException) exception).getErrors().size() == 1) {
        exception = ((MultiException) exception).getErrors().get(0);
    }
    return Response.status(INTERNAL_SERVER_ERROR)
                   .type(MediaType.APPLICATION_JSON)
                   .entity(formatException(exception, this.trace()))
                   .build();
}
 
Example #3
Source File: ApplicationConfig.java    From hugegraph with Apache License 2.0 5 votes vote down vote up
@Override
public GraphManager provide() {
    if (this.manager == null) {
        String message = "Please wait for the server to initialize";
        throw new MultiException(new HugeException(message), false);
    }
    return this.manager;
}
 
Example #4
Source File: DefaultDockerClient.java    From docker-client with Apache License 2.0 5 votes vote down vote up
private RuntimeException propagate(final String method, final WebTarget resource,
                                   final Exception ex)
    throws DockerException, InterruptedException {
  Throwable cause = ex.getCause();

  // Sometimes e is a org.glassfish.hk2.api.MultiException
  // which contains the cause we're actually interested in.
  // So we unpack it here.
  if (ex instanceof MultiException) {
    cause = cause.getCause();
  }

  Response response = null;
  if (cause instanceof ResponseProcessingException) {
    response = ((ResponseProcessingException) cause).getResponse();
  } else if (cause instanceof WebApplicationException) {
    response = ((WebApplicationException) cause).getResponse();
  } else if ((cause instanceof ProcessingException) && (cause.getCause() != null)) {
    // For a ProcessingException, The exception message or nested Throwable cause SHOULD contain
    // additional information about the reason of the processing failure.
    cause = cause.getCause();
  }

  if (response != null) {
    throw new DockerRequestException(method, resource.getUri(), response.getStatus(),
                                     message(response), cause);
  } else if ((cause instanceof SocketTimeoutException)
             || (cause instanceof ConnectTimeoutException)) {
    throw new DockerTimeoutException(method, resource.getUri(), ex);
  } else if ((cause instanceof InterruptedIOException)
             || (cause instanceof InterruptedException)) {
    throw new InterruptedException("Interrupted: " + method + " " + resource);
  } else {
    throw new DockerException(ex);
  }
}
 
Example #5
Source File: ServiceLocatorGenerator.java    From ameba with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public ServiceLocator create(String name, ServiceLocator parent) {
    ServiceLocator retVal = super.create(name, parent);
    DynamicConfigurationService dcs = retVal.getService(DynamicConfigurationService.class);
    Populator populator = dcs.getPopulator();

    try {
        populator.populate();
    } catch (IOException e) {
        throw new MultiException(e);
    }
    return retVal;
}