public abstract class ErrorDetail<SelfT extends ErrorDetail<SelfT>>
extends java.lang.Object
implements java.io.Serializable
WARNING: The class and its APIs are still experimental and subject to change.
Modifier and Type | Field and Description |
---|---|
private java.lang.Throwable |
cause |
private java.lang.String |
message |
private com.google.common.collect.ImmutableList<java.lang.Object> |
sources |
Modifier | Constructor and Description |
---|---|
protected |
ErrorDetail(java.lang.String message,
java.util.List<java.lang.Object> sources,
java.lang.Throwable cause) |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object o) |
void |
format(int index,
java.util.List<ErrorDetail<?>> mergeableErrors,
java.util.Formatter formatter)
Formats this error along with other errors that are mergeable with this error.
|
protected abstract void |
formatDetail(java.util.List<ErrorDetail<?>> mergeableErrors,
java.util.Formatter formatter)
Formats the detail of this error message along with other errors that are mergeable with this
error.
|
java.lang.Throwable |
getCause() |
protected java.util.Optional<java.lang.String> |
getErrorIdentifier()
Returns an optional string identifier for this error.
|
protected java.util.Optional<java.lang.String> |
getLearnMoreLink()
Returns an optional link to additional documentation about this error to be included in the
formatted error message.
|
java.lang.String |
getMessage() |
java.util.List<java.lang.Object> |
getSources() |
int |
hashCode() |
boolean |
isMergeable(ErrorDetail<?> otherError)
Returns true if this error can be merged with the
otherError and formatted together. |
abstract SelfT |
withSources(java.util.List<java.lang.Object> newSources)
Returns a new instance of the same
ErrorDetail with updated sources. |
private final java.lang.String message
private final com.google.common.collect.ImmutableList<java.lang.Object> sources
private final java.lang.Throwable cause
protected ErrorDetail(java.lang.String message, java.util.List<java.lang.Object> sources, java.lang.Throwable cause)
public boolean isMergeable(ErrorDetail<?> otherError)
otherError
and formatted together.
By default this return false and implementations that support merging with other errors should override this method.
public final void format(int index, java.util.List<ErrorDetail<?>> mergeableErrors, java.util.Formatter formatter)
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
isMergeable(com.google.inject.spi.ErrorDetail<?>)
. The list will be empty if non of the other errors are mergable with this
error.
Formatted error has the following structure:
index
- index for this errormergeableErrors
- list of errors that are mergeable with this errorformatter
- for printing the error messageprotected abstract void formatDetail(java.util.List<ErrorDetail<?>> mergeableErrors, java.util.Formatter formatter)
format(int, java.util.List<com.google.inject.spi.ErrorDetail<?>>, java.util.Formatter)
.
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
isMergeable(com.google.inject.spi.ErrorDetail<?>)
. The list will be empty if non of the other errors are mergable with this
error.
mergeableErrors
- list of errors that are mergeable with this errorformatter
- for printing the error messageprotected java.util.Optional<java.lang.String> getLearnMoreLink()
protected java.util.Optional<java.lang.String> getErrorIdentifier()
public java.lang.String getMessage()
public java.util.List<java.lang.Object> getSources()
public java.lang.Throwable getCause()
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public abstract SelfT withSources(java.util.List<java.lang.Object> newSources)
ErrorDetail
with updated sources.