Class Errors
java.lang.Object
org.opensearch.common.inject.internal.Errors
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.
- Opensearch.internal:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddMessage
(String messageFormat, Object... arguments) addMessage
(Message message) ambiguousTypeConversion
(String stringValue, Object source, TypeLiteral<?> type, MatcherAndConverter a, MatcherAndConverter b) bindingAlreadySet
(Key<?> key, Object source) cannotBindToGuiceType
(String simpleName) cannotInjectInnerClass
(Class<?> type) cannotInjectTypeLiteralOf
(Type unsupportedType) cannotSatisfyCircularDependency
(Class<?> expectedType) <T> T
checkForNull
(T value, Object source, Dependency<?> dependency) Returnsvalue
if it is non-null allowed to be null.childBindingAlreadySet
(Key<?> key) conversionError
(String stringValue, Object source, TypeLiteral<?> type, MatcherAndConverter matchingConverter, RuntimeException cause) conversionTypeError
(String stringValue, Object source, TypeLiteral<?> type, MatcherAndConverter matchingConverter, Object converted) static Object
converterReturnedNull
(String stringValue, Object source, TypeLiteral<?> type, MatcherAndConverter matchingConverter) duplicateBindingAnnotations
(Member member, Class<? extends Annotation> a, Class<? extends Annotation> b) duplicateScopeAnnotations
(Class<? extends Annotation> a, Class<? extends Annotation> b) duplicateScopes
(Scope existing, Class<? extends Annotation> annotationType, Scope scope) errorInjectingMethod
(Throwable cause) errorInProvider
(RuntimeException runtimeException) errorInUserCode
(Throwable cause, String messageFormat, Object... arguments) errorInUserInjector
(MembersInjector<?> listener, TypeLiteral<?> type, RuntimeException cause) errorNotifyingInjectionListener
(InjectionListener<?> listener, TypeLiteral<?> type, RuntimeException cause) errorNotifyingTypeListener
(TypeListenerBinding listener, TypeLiteral<?> type, Throwable cause) void
exposedButNotBound
(Key<?> key) static String
static String
format
(String heading, Collection<Message> errorMessages) Returns the formatted message for an exception with the specified messages.static void
formatInjectionPoint
(Formatter formatter, Dependency<?> dependency, InjectionPoint injectionPoint) static void
formatSource
(Formatter formatter, Object source) static Collection
<Message> getMessagesFromThrowable
(Throwable throwable) static Throwable
getOnlyCause
(Collection<Message> messages) Returns the cause throwable if there is exactly one cause inmessages
.boolean
merge
(Collection<Message> messages) misplacedBindingAnnotation
(Member member, Annotation bindingAnnotation) missingConstructor
(Class<?> implementation) missingImplementation
(Key key) We use a fairly generic error message here.missingRuntimeRetention
(Object source) notASubtype
(Class<?> implementationType, Class<?> type) optionalConstructor
(Constructor constructor) scopeAnnotationOnAbstractType
(Class<? extends Annotation> scopeAnnotation, Class<?> type, Object source) scopeNotFound
(Class<? extends Annotation> scopeAnnotation) int
size()
subtypeNotProvided
(Class<? extends Provider<?>> providerType, Class<?> type) void
void
void
throwIfNewErrors
(int expectedSize) void
tooManyConstructors
(Class<?> implementation) withSource
(Object source) Returns an instance that usessource
as a reference point for newly added errors.
-
Constructor Details
-
Errors
public Errors() -
Errors
-
-
Method Details
-
withSource
Returns an instance that usessource
as 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(String stringValue, Object source, TypeLiteral<?> type, MatcherAndConverter matchingConverter) -
conversionTypeError
public Errors conversionTypeError(String stringValue, Object source, TypeLiteral<?> type, MatcherAndConverter matchingConverter, Object converted) -
conversionError
public Errors conversionError(String stringValue, Object source, TypeLiteral<?> type, MatcherAndConverter matchingConverter, RuntimeException cause) -
ambiguousTypeConversion
public Errors ambiguousTypeConversion(String stringValue, Object source, TypeLiteral<?> type, MatcherAndConverter a, MatcherAndConverter b) -
bindingToProvider
-
subtypeNotProvided
-
notASubtype
-
recursiveImplementationType
-
recursiveProviderType
-
missingRuntimeRetention
-
missingScopeAnnotation
-
optionalConstructor
-
cannotBindToGuiceType
-
scopeNotFound
-
scopeAnnotationOnAbstractType
public Errors scopeAnnotationOnAbstractType(Class<? extends Annotation> scopeAnnotation, Class<?> type, Object source) -
misplacedBindingAnnotation
-
missingConstructor
-
tooManyConstructors
-
duplicateScopes
public Errors duplicateScopes(Scope existing, Class<? extends Annotation> annotationType, Scope scope) -
voidProviderMethod
-
missingConstantValues
-
cannotInjectInnerClass
-
duplicateBindingAnnotations
public Errors duplicateBindingAnnotations(Member member, Class<? extends Annotation> a, Class<? extends Annotation> b) -
duplicateScopeAnnotations
public Errors duplicateScopeAnnotations(Class<? extends Annotation> a, Class<? extends Annotation> b) -
recursiveBinding
-
bindingAlreadySet
-
childBindingAlreadySet
-
errorInjectingMethod
-
errorNotifyingTypeListener
public Errors errorNotifyingTypeListener(TypeListenerBinding listener, TypeLiteral<?> type, Throwable cause) -
errorInjectingConstructor
-
errorInProvider
-
errorInUserInjector
public Errors errorInUserInjector(MembersInjector<?> listener, TypeLiteral<?> type, RuntimeException cause) -
errorNotifyingInjectionListener
public Errors errorNotifyingInjectionListener(InjectionListener<?> listener, TypeLiteral<?> type, RuntimeException cause) -
exposedButNotBound
-
getMessagesFromThrowable
-
errorInUserCode
-
cannotInjectRawProvider
-
cannotInjectRawMembersInjector
-
cannotInjectTypeLiteralOf
-
cannotInjectRawTypeLiteral
-
cannotSatisfyCircularDependency
-
throwCreationExceptionIfErrorsExist
public void throwCreationExceptionIfErrorsExist() -
throwConfigurationExceptionIfErrorsExist
public void throwConfigurationExceptionIfErrorsExist() -
throwProvisionExceptionIfErrorsExist
public void throwProvisionExceptionIfErrorsExist() -
merge
-
merge
-
getSources
-
throwIfNewErrors
- Throws:
ErrorsException
-
toException
-
hasErrors
public boolean hasErrors() -
addMessage
-
addMessage
-
format
-
getMessages
-
format
Returns the formatted message for an exception with the specified messages. -
checkForNull
Returnsvalue
if it is non-null allowed to be null. Otherwise a message is added and anErrorsException
is 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
-
formatSource
-
formatInjectionPoint
public static void formatInjectionPoint(Formatter formatter, Dependency<?> dependency, InjectionPoint injectionPoint)
-