本文整理汇总了Java中org.elasticsearch.common.inject.ProvisionException类的典型用法代码示例。如果您正苦于以下问题:Java ProvisionException类的具体用法?Java ProvisionException怎么用?Java ProvisionException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ProvisionException类属于org.elasticsearch.common.inject包,在下文中一共展示了ProvisionException类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: invoke
import org.elasticsearch.common.inject.ProvisionException; //导入依赖的package包/类
/**
* When a factory method is invoked, we create a child injector that binds all parameters, then
* use that to get an instance of the return type.
*/
@Override
public Object invoke(Object proxy, final Method method, final Object[] args) throws Throwable {
if (method.getDeclaringClass() == Object.class) {
return method.invoke(this, args);
}
Provider<?> provider = getBindingFromNewInjector(method, args).getProvider();
try {
return provider.get();
} catch (ProvisionException e) {
// if this is an exception declared by the factory method, throw it as-is
if (e.getErrorMessages().size() == 1) {
Message onlyError = Iterables.getOnlyElement(e.getErrorMessages());
Throwable cause = onlyError.getCause();
if (cause != null && canRethrow(method, cause)) {
throw cause;
}
}
throw e;
}
}
示例2: getMessagesFromThrowable
import org.elasticsearch.common.inject.ProvisionException; //导入依赖的package包/类
public static Collection<Message> getMessagesFromThrowable(Throwable throwable) {
if (throwable instanceof ProvisionException) {
return ((ProvisionException) throwable).getErrorMessages();
} else if (throwable instanceof ConfigurationException) {
return ((ConfigurationException) throwable).getErrorMessages();
} else if (throwable instanceof CreationException) {
return ((CreationException) throwable).getErrorMessages();
} else {
return emptySet();
}
}
示例3: throwProvisionExceptionIfErrorsExist
import org.elasticsearch.common.inject.ProvisionException; //导入依赖的package包/类
public void throwProvisionExceptionIfErrorsExist() {
if (!hasErrors()) {
return;
}
throw new ProvisionException(getMessages());
}
示例4: getMessagesFromThrowable
import org.elasticsearch.common.inject.ProvisionException; //导入依赖的package包/类
public static Collection<Message> getMessagesFromThrowable(Throwable throwable) {
if (throwable instanceof ProvisionException) {
return ((ProvisionException) throwable).getErrorMessages();
} else if (throwable instanceof ConfigurationException) {
return ((ConfigurationException) throwable).getErrorMessages();
} else if (throwable instanceof CreationException) {
return ((CreationException) throwable).getErrorMessages();
} else {
return ImmutableSet.of();
}
}
示例5: testThatBrokenRegexLeadsToException
import org.elasticsearch.common.inject.ProvisionException; //导入依赖的package包/类
@Test(expected = ProvisionException.class)
public void testThatBrokenRegexLeadsToException() throws Exception {
String excludeRegex = "*.peakCount";
createNode(clusterName, GRAPHITE_SERVER_PORT, "1s", null, excludeRegex, null);
}