Class Errors
java.lang.Object
org.elasticsearch.common.inject.internal.Errors
public final class Errors
extends java.lang.Object
A collection of error messages. If this type is passed as a method parameter, the method is
considered to have executed successfully only if new errors were not added to this collection.
Errors can be chained to provide additional context. To add context, call withSource(java.lang.Object)
to create a new Errors instance that contains additional context. All messages added to the
returned instance will contain full context.
To avoid messages with redundant context, withSource(java.lang.Object) should be added sparingly. A
good rule of thumb is to assume a method's caller has already specified enough context to
identify that method. When calling a method that's defined in a different context, call that
method with an errors object that includes its context.
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description ErrorsaddMessage(java.lang.String messageFormat, java.lang.Object... arguments)ErrorsaddMessage(Message message)ErrorsambiguousTypeConversion(java.lang.String stringValue, java.lang.Object source, TypeLiteral<?> type, MatcherAndConverter a, MatcherAndConverter b)ErrorsbindingAlreadySet(Key<?> key, java.lang.Object source)ErrorsbindingToProvider()ErrorscannotBindToGuiceType(java.lang.String simpleName)ErrorscannotInjectInnerClass(java.lang.Class<?> type)ErrorscannotInjectRawMembersInjector()ErrorscannotInjectRawProvider()ErrorscannotInjectRawTypeLiteral()ErrorscannotInjectTypeLiteralOf(java.lang.reflect.Type unsupportedType)ErrorscannotSatisfyCircularDependency(java.lang.Class<?> expectedType)<T> TcheckForNull(T value, java.lang.Object source, Dependency<?> dependency)Returnsvalueif it is non-null allowed to be null.ErrorschildBindingAlreadySet(Key<?> key)ErrorsconversionError(java.lang.String stringValue, java.lang.Object source, TypeLiteral<?> type, MatcherAndConverter matchingConverter, java.lang.RuntimeException cause)ErrorsconversionTypeError(java.lang.String stringValue, java.lang.Object source, TypeLiteral<?> type, MatcherAndConverter matchingConverter, java.lang.Object converted)static java.lang.Objectconvert(java.lang.Object o)ErrorsconverterReturnedNull(java.lang.String stringValue, java.lang.Object source, TypeLiteral<?> type, MatcherAndConverter matchingConverter)ErrorsduplicateBindingAnnotations(java.lang.reflect.Member member, java.lang.Class<? extends java.lang.annotation.Annotation> a, java.lang.Class<? extends java.lang.annotation.Annotation> b)ErrorsduplicateScopeAnnotations(java.lang.Class<? extends java.lang.annotation.Annotation> a, java.lang.Class<? extends java.lang.annotation.Annotation> b)ErrorsduplicateScopes(Scope existing, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType, Scope scope)ErrorserrorInjectingConstructor(java.lang.Throwable cause)ErrorserrorInjectingMethod(java.lang.Throwable cause)ErrorserrorInProvider(java.lang.RuntimeException runtimeException)ErrorserrorInUserCode(java.lang.Throwable cause, java.lang.String messageFormat, java.lang.Object... arguments)ErrorserrorInUserInjector(MembersInjector<?> listener, TypeLiteral<?> type, java.lang.RuntimeException cause)ErrorserrorNotifyingInjectionListener(InjectionListener<?> listener, TypeLiteral<?> type, java.lang.RuntimeException cause)ErrorserrorNotifyingTypeListener(TypeListenerBinding listener, TypeLiteral<?> type, java.lang.Throwable cause)voidexposedButNotBound(Key<?> key)static java.lang.Stringformat(java.lang.String messageFormat, java.lang.Object... arguments)static java.lang.Stringformat(java.lang.String heading, java.util.Collection<Message> errorMessages)Returns the formatted message for an exception with the specified messages.static voidformatInjectionPoint(java.util.Formatter formatter, Dependency<?> dependency, InjectionPoint injectionPoint)static voidformatSource(java.util.Formatter formatter, java.lang.Object source)java.util.List<Message>getMessages()static java.util.Collection<Message>getMessagesFromThrowable(java.lang.Throwable throwable)static java.lang.ThrowablegetOnlyCause(java.util.Collection<Message> messages)Returns the cause throwable if there is exactly one cause inmessages.java.util.List<java.lang.Object>getSources()booleanhasErrors()Errorsmerge(java.util.Collection<Message> messages)Errorsmerge(Errors moreErrors)ErrorsmisplacedBindingAnnotation(java.lang.reflect.Member member, java.lang.annotation.Annotation bindingAnnotation)ErrorsmissingConstantValues()ErrorsmissingConstructor(java.lang.Class<?> implementation)ErrorsmissingImplementation(Key key)We use a fairly generic error message here.ErrorsmissingRuntimeRetention(java.lang.Object source)ErrorsmissingScopeAnnotation()ErrorsnotASubtype(java.lang.Class<?> implementationType, java.lang.Class<?> type)ErrorsoptionalConstructor(java.lang.reflect.Constructor constructor)ErrorsrecursiveBinding()ErrorsrecursiveImplementationType()ErrorsrecursiveProviderType()ErrorsscopeAnnotationOnAbstractType(java.lang.Class<? extends java.lang.annotation.Annotation> scopeAnnotation, java.lang.Class<?> type, java.lang.Object source)ErrorsscopeNotFound(java.lang.Class<? extends java.lang.annotation.Annotation> scopeAnnotation)intsize()ErrorssubtypeNotProvided(java.lang.Class<? extends Provider<?>> providerType, java.lang.Class<?> type)voidthrowConfigurationExceptionIfErrorsExist()voidthrowCreationExceptionIfErrorsExist()voidthrowIfNewErrors(int expectedSize)voidthrowProvisionExceptionIfErrorsExist()ErrorsExceptiontoException()ErrorstooManyConstructors(java.lang.Class<?> implementation)ErrorsvoidProviderMethod()ErrorswithSource(java.lang.Object source)Returns an instance that usessourceas a reference point for newly added errors.
-
Constructor Details
-
Method Details
-
withSource
Returns an instance that usessourceas a reference point for newly added errors. -
missingImplementation
We use a fairly generic error message here. The motivation is to share the same message for both bind time errors:
...and at provide-time errors:Guice.createInjector(new AbstractModule() { public void configure() { bind(Runnable.class); } }
Otherwise we need to know who's calling when resolving a just-in-time binding, which makes things unnecessarily complex.Guice.createInjector().getInstance(Runnable.class); -
converterReturnedNull
public Errors converterReturnedNull(java.lang.String stringValue, java.lang.Object source, TypeLiteral<?> type, MatcherAndConverter matchingConverter) -
conversionTypeError
public Errors conversionTypeError(java.lang.String stringValue, java.lang.Object source, TypeLiteral<?> type, MatcherAndConverter matchingConverter, java.lang.Object converted) -
conversionError
public Errors conversionError(java.lang.String stringValue, java.lang.Object source, TypeLiteral<?> type, MatcherAndConverter matchingConverter, java.lang.RuntimeException cause) -
ambiguousTypeConversion
public Errors ambiguousTypeConversion(java.lang.String stringValue, java.lang.Object source, TypeLiteral<?> type, MatcherAndConverter a, MatcherAndConverter b) -
bindingToProvider
-
subtypeNotProvided
-
notASubtype
-
recursiveImplementationType
-
recursiveProviderType
-
missingRuntimeRetention
-
missingScopeAnnotation
-
optionalConstructor
-
cannotBindToGuiceType
-
scopeNotFound
public Errors scopeNotFound(java.lang.Class<? extends java.lang.annotation.Annotation> scopeAnnotation) -
scopeAnnotationOnAbstractType
public Errors scopeAnnotationOnAbstractType(java.lang.Class<? extends java.lang.annotation.Annotation> scopeAnnotation, java.lang.Class<?> type, java.lang.Object source) -
misplacedBindingAnnotation
public Errors misplacedBindingAnnotation(java.lang.reflect.Member member, java.lang.annotation.Annotation bindingAnnotation) -
missingConstructor
-
tooManyConstructors
-
duplicateScopes
-
voidProviderMethod
-
missingConstantValues
-
cannotInjectInnerClass
-
duplicateBindingAnnotations
public Errors duplicateBindingAnnotations(java.lang.reflect.Member member, java.lang.Class<? extends java.lang.annotation.Annotation> a, java.lang.Class<? extends java.lang.annotation.Annotation> b) -
duplicateScopeAnnotations
public Errors duplicateScopeAnnotations(java.lang.Class<? extends java.lang.annotation.Annotation> a, java.lang.Class<? extends java.lang.annotation.Annotation> b) -
recursiveBinding
-
bindingAlreadySet
-
childBindingAlreadySet
-
errorInjectingMethod
-
errorNotifyingTypeListener
public Errors errorNotifyingTypeListener(TypeListenerBinding listener, TypeLiteral<?> type, java.lang.Throwable cause) -
errorInjectingConstructor
-
errorInProvider
-
errorInUserInjector
public Errors errorInUserInjector(MembersInjector<?> listener, TypeLiteral<?> type, java.lang.RuntimeException cause) -
errorNotifyingInjectionListener
public Errors errorNotifyingInjectionListener(InjectionListener<?> listener, TypeLiteral<?> type, java.lang.RuntimeException cause) -
exposedButNotBound
-
getMessagesFromThrowable
public static java.util.Collection<Message> getMessagesFromThrowable(java.lang.Throwable throwable) -
errorInUserCode
public Errors errorInUserCode(java.lang.Throwable cause, java.lang.String messageFormat, java.lang.Object... arguments) -
cannotInjectRawProvider
-
cannotInjectRawMembersInjector
-
cannotInjectTypeLiteralOf
-
cannotInjectRawTypeLiteral
-
cannotSatisfyCircularDependency
-
throwCreationExceptionIfErrorsExist
public void throwCreationExceptionIfErrorsExist() -
throwConfigurationExceptionIfErrorsExist
public void throwConfigurationExceptionIfErrorsExist() -
throwProvisionExceptionIfErrorsExist
public void throwProvisionExceptionIfErrorsExist() -
merge
-
merge
-
getSources
public java.util.List<java.lang.Object> getSources() -
throwIfNewErrors
- Throws:
ErrorsException
-
toException
-
hasErrors
public boolean hasErrors() -
addMessage
-
addMessage
-
format
public static java.lang.String format(java.lang.String messageFormat, java.lang.Object... arguments) -
getMessages
-
format
public static java.lang.String format(java.lang.String heading, java.util.Collection<Message> errorMessages)Returns the formatted message for an exception with the specified messages. -
checkForNull
public <T> T checkForNull(T value, java.lang.Object source, Dependency<?> dependency) throws ErrorsExceptionReturnsvalueif it is non-null allowed to be null. Otherwise a message is added and anErrorsExceptionis thrown.- Throws:
ErrorsException
-
getOnlyCause
Returns the cause throwable if there is exactly one cause inmessages. If there are zero or multiple messages with causes, null is returned. -
size
public int size() -
convert
public static java.lang.Object convert(java.lang.Object o) -
formatSource
public static void formatSource(java.util.Formatter formatter, java.lang.Object source) -
formatInjectionPoint
public static void formatInjectionPoint(java.util.Formatter formatter, Dependency<?> dependency, InjectionPoint injectionPoint)
-