Package com.google.inject.internal
Class Errors
java.lang.Object
com.google.inject.internal.Errors
- All Implemented Interfaces:
Serializable
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.
- Author:
- jessewilson@google.com (Jesse Wilson)
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddMessage
(ErrorId errorId, String messageFormat, Object... arguments) addMessage
(Message message) addMessage
(String messageFormat, Object... arguments) ambiguousTypeConversion
(String stringValue, Object source, TypeLiteral<?> type, TypeConverterBinding a, TypeConverterBinding b) aopDisabled
(InterceptorBinding binding) atInjectRequired
(TypeLiteral<?> type) atTargetIsMissingParameter
(Annotation bindingAnnotation, String parameterName, Class<?> clazz) bindingAlreadySet
(Key<?> key, Object source) cannotBindToGuiceType
(String simpleName) cannotInjectAbstractMethod
(Method method) cannotInjectFinalField
(Field field) cannotInjectInnerClass
(Class<?> type) cannotInjectLocalClass
(Class<?> type) cannotInjectTypeLiteralOf
(Type unsupportedType) childBindingAlreadySet
(Key<?> key, Set<Object> sources) constructorNotDefinedByType
(Constructor<?> constructor, TypeLiteral<?> type) conversionError
(String stringValue, Object source, TypeLiteral<?> type, TypeConverterBinding typeConverterBinding, RuntimeException cause) conversionTypeError
(String stringValue, Object source, TypeLiteral<?> type, TypeConverterBinding typeConverterBinding, Object converted) static Object
static Object
convert
(Object o, ElementSource source) converterReturnedNull
(String stringValue, Object source, TypeLiteral<?> type, TypeConverterBinding typeConverterBinding) duplicateBindingAnnotations
(Member member, Class<? extends Annotation> a, Class<? extends Annotation> b) <K,
V> Errors duplicateMapKey
(Key<Map<K, V>> mapKey, com.google.common.collect.Multimap<K, Binding<V>> duplicates) duplicateScopeAnnotations
(Class<? extends Annotation> a, Class<? extends Annotation> b) duplicateScopes
(ScopeBinding existing, Class<? extends Annotation> annotationType, Scope scope) errorCheckingDuplicateBinding
(Key<?> key, Object source, Throwable t) errorEnhancingClass
(Class<?> clazz, Throwable cause) errorInUserCode
(Throwable cause, String messageFormat, Object... arguments) errorNotifyingTypeListener
(TypeListenerBinding listener, TypeLiteral<?> type, Throwable cause) exposedButNotBound
(Key<?> key) static String
static void
formatSource
(Formatter formatter, Object source) static Collection
<Message> getMessagesFromThrowable
(Throwable throwable) boolean
jitBindingAlreadySet
(Key<?> key) jitDisabled
(Key<?> key) jitDisabledInParent
(Key<?> key) keyNotFullySpecified
(TypeLiteral<?> typeLiteral) merge
(Collection<Message> messages) misplacedBindingAnnotation
(Member member, Annotation bindingAnnotation) missingConstructor
(TypeLiteral<?> type) missingImplementation
(Key<?> key) We use a fairly generic error message here.missingRuntimeRetention
(Class<? extends Annotation> annotation) missingScopeAnnotation
(Class<? extends Annotation> annotation) notASubtype
(Class<?> implementationType, Class<?> type) optionalConstructor
(Constructor<?> constructor) recursiveBinding
(Key<?> key, Key<?> linkedKey) scopeAnnotationOnAbstractType
(Class<? extends Annotation> scopeAnnotation, Class<?> type, Object source) scopeNotFound
(Class<? extends Annotation> scopeAnnotation) int
size()
staticInjectionOnInterface
(Class<?> clazz) 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. -
aopDisabled
-
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);
-
jitDisabled
-
jitDisabledInParent
-
atInjectRequired
-
converterReturnedNull
public Errors converterReturnedNull(String stringValue, Object source, TypeLiteral<?> type, TypeConverterBinding typeConverterBinding) -
conversionTypeError
public Errors conversionTypeError(String stringValue, Object source, TypeLiteral<?> type, TypeConverterBinding typeConverterBinding, Object converted) -
conversionError
public Errors conversionError(String stringValue, Object source, TypeLiteral<?> type, TypeConverterBinding typeConverterBinding, RuntimeException cause) -
ambiguousTypeConversion
public Errors ambiguousTypeConversion(String stringValue, Object source, TypeLiteral<?> type, TypeConverterBinding a, TypeConverterBinding b) -
bindingToProvider
-
notASubtype
-
recursiveImplementationType
-
recursiveProviderType
-
missingRuntimeRetention
-
missingScopeAnnotation
-
optionalConstructor
-
cannotBindToGuiceType
-
scopeNotFound
-
scopeAnnotationOnAbstractType
public Errors scopeAnnotationOnAbstractType(Class<? extends Annotation> scopeAnnotation, Class<?> type, Object source) -
misplacedBindingAnnotation
-
missingConstructor
-
tooManyConstructors
-
constructorNotDefinedByType
-
duplicateMapKey
-
duplicateScopes
public Errors duplicateScopes(ScopeBinding existing, Class<? extends Annotation> annotationType, Scope scope) -
voidProviderMethod
-
missingConstantValues
-
cannotInjectInnerClass
-
cannotInjectLocalClass
-
duplicateBindingAnnotations
public Errors duplicateBindingAnnotations(Member member, Class<? extends Annotation> a, Class<? extends Annotation> b) -
staticInjectionOnInterface
-
cannotInjectFinalField
-
atTargetIsMissingParameter
public Errors atTargetIsMissingParameter(Annotation bindingAnnotation, String parameterName, Class<?> clazz) -
cannotInjectAbstractMethod
-
cannotInjectMethodWithTypeParameters
-
duplicateScopeAnnotations
public Errors duplicateScopeAnnotations(Class<? extends Annotation> a, Class<? extends Annotation> b) -
recursiveBinding
-
bindingAlreadySet
-
jitBindingAlreadySet
-
childBindingAlreadySet
-
errorCheckingDuplicateBinding
-
errorNotifyingTypeListener
public Errors errorNotifyingTypeListener(TypeListenerBinding listener, TypeLiteral<?> type, Throwable cause) -
exposedButNotBound
-
keyNotFullySpecified
-
errorEnhancingClass
-
getMessagesFromThrowable
-
errorInUserCode
-
cannotInjectRawProvider
-
cannotInjectRawMembersInjector
-
cannotInjectTypeLiteralOf
-
cannotInjectRawTypeLiteral
-
throwCreationExceptionIfErrorsExist
public void throwCreationExceptionIfErrorsExist() -
throwConfigurationExceptionIfErrorsExist
public void throwConfigurationExceptionIfErrorsExist() -
throwProvisionExceptionIfErrorsExist
public void throwProvisionExceptionIfErrorsExist() -
merge
-
merge
-
merge
-
throwIfNewErrors
- Throws:
ErrorsException
-
toException
-
hasErrors
public boolean hasErrors() -
addMessage
-
addMessage
-
addMessage
-
format
-
getMessages
-
size
public int size() -
convert
-
convert
-
formatSource
-