本文整理了Java中com.google.inject.spi.Message.getCause()
方法的一些代码示例,展示了Message.getCause()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.getCause()
方法的具体详情如下:
包路径:com.google.inject.spi.Message
类名称:Message
方法名:getCause
[英]Returns the throwable that caused this message, or null if this message was not caused by a throwable.
[中]返回导致此消息的可丢弃项,如果此消息不是由可丢弃项引起的,则返回null。
代码示例来源:origin: com.google.inject/guice
@Override
public Boolean visit(Message message) {
if (message.getCause() != null) {
String rootMessage = getRootMessage(message.getCause());
logger.log(
Level.INFO,
"An exception was caught and reported. Message: " + rootMessage,
message.getCause());
}
errors.addMessage(message);
return true;
}
代码示例来源:origin: Graylog2/graylog2-server
@Override
protected void annotateInjectorExceptions(Collection<Message> messages) {
super.annotateInjectorExceptions(messages);
for (Message message : messages) {
if (message.getCause() instanceof MongoException) {
MongoException e = (MongoException) message.getCause();
LOG.error(UI.wallString("Unable to connect to MongoDB. Is it running and the configuration correct?\n" +
"Details: " + e.getMessage()));
System.exit(-1);
}
}
}
代码示例来源:origin: com.google.inject/guice
/**
* Returns the cause throwable if there is exactly one cause in {@code messages}. If there are
* zero or multiple messages with causes, null is returned.
*/
public static Throwable getOnlyCause(Collection<Message> messages) {
Throwable onlyCause = null;
for (Message message : messages) {
Throwable messageCause = message.getCause();
if (messageCause == null) {
continue;
}
if (onlyCause != null && !ThrowableEquivalence.INSTANCE.equivalent(onlyCause, messageCause)) {
return null;
}
onlyCause = messageCause;
}
return onlyCause;
}
代码示例来源:origin: com.google.inject/guice
/** Prepends the list of sources to the given {@link Message} */
static Message mergeSources(List<Object> sources, Message message) {
List<Object> messageSources = message.getSources();
// It is possible that the end of getSources() and the beginning of message.getSources() are
// equivalent, in this case we should drop the repeated source when joining the lists. The
// most likely scenario where this would happen is when a scoped binding throws an exception,
// due to the fact that InternalFactoryToProviderAdapter applies the binding source when
// merging errors.
if (!sources.isEmpty()
&& !messageSources.isEmpty()
&& Objects.equal(messageSources.get(0), sources.get(sources.size() - 1))) {
messageSources = messageSources.subList(1, messageSources.size());
}
return new Message(
ImmutableList.builder().addAll(sources).addAll(messageSources).build(),
message.getMessage(),
message.getCause());
}
代码示例来源:origin: Graylog2/graylog2-server
protected void annotateInjectorExceptions(Collection<Message> messages) {
for (Message message : messages) {
//noinspection ThrowableResultOfMethodCallIgnored
final Throwable rootCause = ExceptionUtils.getRootCause(message.getCause());
if (rootCause instanceof NodeIdPersistenceException) {
LOG.error(UI.wallString(
"Unable to read or persist your NodeId file. This means your node id file (" + configuration.getNodeIdFile() + ") is not readable or writable by the current user. The following exception might give more information: " + message));
System.exit(-1);
} else if (rootCause instanceof AccessDeniedException) {
LOG.error(UI.wallString("Unable to access file " + rootCause.getMessage()));
System.exit(-2);
} else {
// other guice error, still print the raw messages
// TODO this could potentially print duplicate messages depending on what a subclass does...
LOG.error("Guice error (more detail on log level debug): {}", message.getMessage());
if (rootCause != null) {
LOG.debug("Stacktrace:", rootCause);
}
}
}
}
代码示例来源:origin: com.google.inject/guice
Throwable cause = errorMessage.getCause();
if (displayCauses && cause != null) {
Equivalence.Wrapper<Throwable> causeEquivalence = ThrowableEquivalence.INSTANCE.wrap(cause);
代码示例来源:origin: torodb/stampede
} catch (CreationException ex) {
ex.getErrorMessages().stream().forEach(m -> {
if (m.getCause() != null) {
LOGGER.error(m.getCause().getMessage());
} else {
LOGGER.error(m.getMessage());
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/com.google.inject
@Override public Boolean visit(Message message) {
if (message.getCause() != null) {
String rootMessage = getRootMessage(message.getCause());
logger.log(Level.INFO,
"An exception was caught and reported. Message: " + rootMessage,
message.getCause());
}
errors.addMessage(message);
return true;
}
代码示例来源:origin: org.sonatype.sisu/sisu-guice
@Override
public Boolean visit(Message message) {
if (message.getCause() != null) {
String rootMessage = getRootMessage(message.getCause());
logger.log(
Level.INFO,
"An exception was caught and reported. Message: " + rootMessage,
message.getCause());
}
errors.addMessage(message);
return true;
}
代码示例来源:origin: com.google/inject
@Override public Boolean visit(Message message) {
if (message.getCause() != null) {
String rootMessage = getRootMessage(message.getCause());
logger.log(Level.INFO,
"An exception was caught and reported. Message: " + rootMessage,
message.getCause());
}
errors.addMessage(message);
return true;
}
代码示例来源:origin: com.jwebmp.inject/guice
@Override
public Boolean visit(Message message) {
if (message.getCause() != null) {
String rootMessage = getRootMessage(message.getCause());
logger.log(
Level.INFO,
"An exception was caught and reported. Message: " + rootMessage,
message.getCause());
}
errors.addMessage(message);
return true;
}
代码示例来源:origin: Nextdoor/bender
@Override public Boolean visit(Message message) {
if (message.getCause() != null) {
String rootMessage = getRootMessage(message.getCause());
logger.log(Level.INFO,
"An exception was caught and reported. Message: " + rootMessage,
message.getCause());
}
errors.addMessage(message);
return true;
}
代码示例来源:origin: org.graylog2/graylog2-server
@Override
protected void annotateInjectorExceptions(Collection<Message> messages) {
super.annotateInjectorExceptions(messages);
for (Message message : messages) {
if (message.getCause() instanceof MongoException) {
MongoException e = (MongoException) message.getCause();
LOG.error(UI.wallString("Unable to connect to MongoDB. Is it running and the configuration correct?\n" +
"Details: " + e.getMessage()));
System.exit(-1);
}
}
}
代码示例来源:origin: com.proofpoint.platform/configuration
@Override
public void onError(Message errorMessage)
{
problems.addError(errorMessage.getCause(),
"Configuration setter method [%s] Map value type %s: %s",
method.toGenericString(),
valueClass.getSimpleName(),
errorMessage.getMessage());
}
代码示例来源:origin: com.commercetools.sunrise/common
@Override
protected CompletionStage<Result> onDevServerError(final Http.RequestHeader request, final UsefulException exception) {
return Optional.ofNullable(exception.getCause())
.map(Throwable::getCause)
.filter(e -> e instanceof ProvisionException)
.map(e -> (ProvisionException) e)
.filter(e -> e.getErrorMessages().stream().anyMatch(m -> m.getCause() instanceof SphereClientCredentialsException))
.map(e -> (CompletionStage<Result>) CompletableFuture.completedFuture(Results.internalServerError(views.html.defaultpages.devError.render(playEditor, new SphereCredentialsUsefulException(exception)))))
.orElseGet(() -> super.onDevServerError(request, exception));
}
代码示例来源:origin: org.xbib/guice
private Message merge(Message message) {
List<Object> sources = Lists.newArrayList();
sources.addAll(getSources());
sources.addAll(message.getSources());
return new Message(sources, message.getMessage(), message.getCause());
}
代码示例来源:origin: io.github.gwtplus.gin/gin
public void visitElementsAndReportErrors(List<Element> elements) {
visitElements(elements);
// Capture any binding errors, any of which we treat as fatal.
if (!messages.isEmpty()) {
for (Message message : messages) {
// tostring has both source and message so use that
errorManager.logError(message.toString(), message.getCause());
}
}
}
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/com.google.inject
private Message merge(Message message) {
List<Object> sources = Lists.newArrayList();
sources.addAll(getSources());
sources.addAll(message.getSources());
return new Message(sources, message.getMessage(), message.getCause());
}
代码示例来源:origin: Nextdoor/bender
private Message merge(Message message) {
List<Object> sources = Lists.newArrayList();
sources.addAll(getSources());
sources.addAll(message.getSources());
return new Message(sources, message.getMessage(), message.getCause());
}
代码示例来源:origin: org.guiceyfruit/guiceyfruit-core
private Message merge(Message message) {
List<Object> sources = Lists.newArrayList();
sources.addAll(this.sources);
sources.addAll(message.getSources());
return new Message(stripDuplicates(sources), message.getMessage(), message.getCause());
}
内容来源于网络,如有侵权,请联系作者删除!