Class ErrorDetail<SelfT extends ErrorDetail<SelfT>>
- java.lang.Object
-
- com.google.inject.spi.ErrorDetail<SelfT>
-
- All Implemented Interfaces:
java.io.Serializable
public abstract class ErrorDetail<SelfT extends ErrorDetail<SelfT>> extends java.lang.Object implements java.io.Serializable
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.
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ErrorDetail(java.lang.String message, java.util.List<java.lang.Object> sources, java.lang.Throwable cause)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method 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 theotherError
and formatted together.abstract SelfT
withSources(java.util.List<java.lang.Object> newSources)
Returns a new instance of the sameErrorDetail
with updated sources.
-
-
-
Method Detail
-
isMergeable
public boolean isMergeable(ErrorDetail<?> otherError)
Returns true if this error can be merged with theotherError
and formatted together.By default this return false and implementations that support merging with other errors should override this method.
-
format
public final 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.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 callingisMergeable(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:
- Summary of the error
- Details about the error such as the source of the error
- Hints for fixing the error if available
- Link to the documentation on this error in greater detail
- Parameters:
index
- index for this errormergeableErrors
- list of errors that are mergeable with this errorformatter
- for printing the error message
-
formatDetail
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. This is called fromformat(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 callingisMergeable(com.google.inject.spi.ErrorDetail<?>)
. The list will be empty if non of the other errors are mergable with this error.- Parameters:
mergeableErrors
- list of errors that are mergeable with this errorformatter
- for printing the error message
-
getLearnMoreLink
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.
-
getErrorIdentifier
protected java.util.Optional<java.lang.String> getErrorIdentifier()
Returns an optional string identifier for this error.
-
getMessage
public java.lang.String getMessage()
-
getSources
public java.util.List<java.lang.Object> getSources()
-
getCause
public java.lang.Throwable getCause()
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
withSources
public abstract SelfT withSources(java.util.List<java.lang.Object> newSources)
Returns a new instance of the sameErrorDetail
with updated sources.
-
-