@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); } } }
/** * 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; }
/** 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()); }
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); } } } }
Throwable cause = errorMessage.getCause(); if (displayCauses && cause != null) { Equivalence.Wrapper<Throwable> causeEquivalence = ThrowableEquivalence.INSTANCE.wrap(cause);
@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); } } }
@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()); }
@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)); }
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()); }
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()); } } }
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()); }
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()); }
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()); }