All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.google.inject.spi.ErrorDetail Maven / Gradle / Ivy

There is a newer version: 7.0.0
Show newest version
package com.google.inject.spi;

import com.google.common.base.Objects;
import com.google.common.collect.ImmutableList;
import com.google.inject.internal.Messages;
import java.io.Serializable;
import java.util.Formatter;
import java.util.List;
import java.util.Optional;

/**
 * Details about a single Guice error and supports formatting itself in the context of other Guice
 * errors.
 *
 * 

WARNING: The class and its APIs are still experimental and subject to change. * * @since 5.0 */ public abstract class ErrorDetail> implements Serializable { private final String message; private final ImmutableList sources; private final Throwable cause; protected ErrorDetail(String message, List sources, Throwable cause) { this.message = message; this.sources = ImmutableList.copyOf(sources); this.cause = cause; } /** * Returns true if this error can be merged with the {@code otherError} and formatted together. * *

By default this return false and implementations that support merging with other errors * should override this method. */ public boolean isMergeable(ErrorDetail otherError) { return false; } /** * Formats this error along with other errors that are mergeable with this error. * *

{@code mergeableErrors} is a list that contains all other errors that are reported in the * same exception that are considered to be mergable with this error base on result of calling * {@link #isMergeable}. The list will be empty if non of the other errors are mergable with this * error. * *

Formatted error has the following structure: * *