List of usage examples for java.lang Exception getCause
public synchronized Throwable getCause()
From source file:com.yahoo.druid.metriccollector.MetricCollectorResourceTest.java
@Test(expected = IllegalArgumentException.class) public void testExceptionBrokerList() throws Throwable { Injector injector = GuiceInjectors.makeStartupInjectorWithModules(ImmutableList.<Module>of()); injector.getInstance(Properties.class).put("druid.metricCollector.kafkaProducerConfig", "{}"); injector.getInstance(Properties.class).put("druid.metricCollector.kafkaTopicPrefix", "testPrefix"); try {/* ww w . j a v a2s .c om*/ injector = Initialization.makeInjectorWithModules(injector, ImmutableList.of(new Module() { @Override public void configure(Binder binder) { binder.bindConstant().annotatedWith(Names.named("serviceName")).to("test"); binder.bindConstant().annotatedWith(Names.named("servicePort")).to(0); binder.bind(Producer.class).toProvider(KafkaProducerProvider.class); JsonConfigProvider.bind(binder, "druid.metricCollector", MetricCollectorConfig.class); } })); injector.getInstance(Producer.class); } catch (Exception e) { throw e.getCause(); } }
From source file:gDao.genericDao.SimpleDaoHandler.java
@Override public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { try {//from w w w. ja v a2 s . c om injectGDao(bean); } catch (Exception e) { throw new BeanInstantiationException(bean.getClass(), e.getMessage(), e.getCause()); } return bean; }
From source file:gDao.genericDao.SimpleDaoHandler.java
@Override public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { try {//w w w . j av a 2 s .c o m injectGDao(bean); } catch (Exception e) { throw new BeanInstantiationException(bean.getClass(), e.getMessage(), e.getCause()); } return bean; }
From source file:lumbermill.internal.http.PostHandler.java
private boolean isUndefinedClientError(Exception e) { return e instanceof JsonParseException || e.getCause() instanceof JsonParseException || e instanceof IllegalArgumentException; }
From source file:com.hiperium.bo.interceptor.UserAuditInterceptor.java
/** * /*from w ww. j av a2 s . c o m*/ * @param context * @return * @throws Exception */ public Object registerUserAudit(InvocationContext context) throws InformationException { this.log.debug("registerUserAudit() - BEGIN: " + context.getMethod().getName()); Object result = null; // Validate the user session ID Object[] params = context.getParameters(); String sessionId = (String) params[params.length - 1]; if (StringUtils.isBlank(sessionId) || !this.sessionManager.isUserLoggedIn(sessionId)) { throw InformationException.generate(EnumI18N.COMMON, EnumInformationException.ACCESS_NOT_ALLOWED, Locale.getDefault()); } try { // Identify the CRUD operation in the method invocation EnumCrudOperation operation = EnumCrudOperation.decodeValue(context.getMethod().getName()); if (EnumCrudOperation.CREATE.equals(operation) || EnumCrudOperation.UPDATE.equals(operation) || EnumCrudOperation.DELETE.equals(operation)) { log.debug("CRUD OPERATION"); result = context.proceed(); // At the return of the method invocation we need to store the audit this.userAuditBO.create(context.getTarget().getClass().getSimpleName(), operation, sessionId); } else if (EnumCrudOperation.READ.equals(operation)) { log.debug("READ OPERATION"); result = context.proceed(); } else { throw InformationException.generate(EnumI18N.COMMON, EnumInformationException.ACCESS_NOT_ALLOWED, this.sessionManager.findUserLocale(sessionId)); } } catch (Exception e) { InformationException infoException = null; if (e.getCause() instanceof InformationException) { infoException = (InformationException) e; throw infoException; } infoException = this.exceptionManager.createMessageException(e, this.sessionManager.findUserLocale(sessionId)); throw infoException; } this.log.debug("registerUserAudit() - END: " + context.getMethod().getName()); return result; }
From source file:com.bradmcevoy.property.BeanPropertySource.java
@Override public Object getProperty(QName name, Resource r) throws NotAuthorizedException { PropertyDescriptor pd = getPropertyDescriptor(r, name.getLocalPart()); if (pd == null) { throw new IllegalArgumentException("no prop: " + name.getLocalPart() + " on " + r.getClass()); }// w ww .j a va 2s. c o m try { return pd.getReadMethod().invoke(r, NOARGS); } catch (Exception ex) { if (ex.getCause() instanceof NotAuthorizedException) { NotAuthorizedException na = (NotAuthorizedException) ex.getCause(); throw na; } else { throw new RuntimeException(name.toString(), ex); } } }
From source file:edu.vt.middleware.gator.util.StaxIndentationHandler.java
/** {@inheritDoc} */ @Override// www.j a v a2 s .co m public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable { final String name = method.getName(); try { if (START_ELEMENT.equals(name)) { indent(); method.invoke(writer, args); stack.push(state); state = OutputState.ELEMENT; } else if (END_ELEMENT.equals(name)) { state = stack.pop(); indent(); method.invoke(writer, args); if (state == OutputState.NONE) { writer.writeCharacters(newline); } } else if (EMPTY_ELEMENT.equals(name)) { indent(); method.invoke(writer, args); } else if (PROC_INSTR.equals(name)) { writer.writeCharacters(newline); method.invoke(writer, args); } else { return method.invoke(writer, args); } } catch (Exception e) { final Throwable cause = e.getCause() != null ? e.getCause() : e; logger.error("StAX write error", cause); throw cause; } return null; }
From source file:com.nextdoor.bender.ipc.es.ElasticSearchTransporterTest.java
@Test(expected = JsonSyntaxException.class) public void testBadJson() throws Throwable { byte[] arr = "{".getBytes(); HttpClient client = getMockClientWithResponse(arr, ContentType.DEFAULT_BINARY, HttpStatus.SC_OK); ElasticSearchTransport transport = new ElasticSearchTransport(client, true); try {/*from www .j av a 2 s . c om*/ transport.sendBatch("foo".getBytes()); } catch (Exception e) { throw e.getCause().getCause(); } }
From source file:de.metas.procurement.webui.MockedTestServerSync.java
public SyncProductSupply getAndRemoveReportedProductSupply(final String uuid) { try {// w w w . j a v a2s . c om final SyncProductSupply productSupply = productSupplies.get(uuid).get(10, TimeUnit.SECONDS); productSupplies.invalidate(uuid); return productSupply; } catch (final Exception e) { throw Throwables.propagate(e.getCause()); } }
From source file:com.threewks.thundr.route.staticResource.StaticResourceRouteResolver.java
@Override public Object resolve(StaticResource action, Request req, Response resp) throws RouteResolverException { try {//www .ja v a2 s .co m serve(action, req, resp); return null; } catch (Exception e) { Throwable original = e.getCause() == null ? e : e.getCause(); throw new BaseException(original, "Failed to load resource %s: %s", req.getRequestPath(), original.getMessage()); } }