Package com.google.inject.internal
Class Errors
- java.lang.Object
-
- com.google.inject.internal.Errors
-
- All Implemented Interfaces:
Serializable
public final class Errors extends Object implements 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:
- Serialized Form
-
-
Method Summary
-
-
-
Constructor Detail
-
Errors
public Errors()
-
Errors
public Errors(Object source)
-
-
Method Detail
-
withSource
public Errors withSource(Object source)
Returns an instance that usessource
as a reference point for newly added errors.
-
aopDisabled
public Errors aopDisabled(InterceptorBinding binding)
-
missingImplementation
public Errors missingImplementation(Key<?> key)
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);
-
atInjectRequired
public Errors atInjectRequired(TypeLiteral<?> type)
-
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
public Errors bindingToProvider()
-
recursiveImplementationType
public Errors recursiveImplementationType()
-
recursiveProviderType
public Errors recursiveProviderType()
-
missingRuntimeRetention
public Errors missingRuntimeRetention(Class<? extends Annotation> annotation)
-
missingScopeAnnotation
public Errors missingScopeAnnotation(Class<? extends Annotation> annotation)
-
optionalConstructor
public Errors optionalConstructor(Constructor<?> constructor)
-
scopeNotFound
public Errors scopeNotFound(Class<? extends Annotation> scopeAnnotation)
-
scopeAnnotationOnAbstractType
public Errors scopeAnnotationOnAbstractType(Class<? extends Annotation> scopeAnnotation, Class<?> type, Object source)
-
misplacedBindingAnnotation
public Errors misplacedBindingAnnotation(Member member, Annotation bindingAnnotation)
-
missingConstructor
public Errors missingConstructor(TypeLiteral<?> type)
-
constructorNotDefinedByType
public Errors constructorNotDefinedByType(Constructor<?> constructor, TypeLiteral<?> type)
-
duplicateMapKey
public <K,V> Errors duplicateMapKey(Key<Map<K,V>> mapKey, com.google.common.collect.Multimap<K,Binding<V>> duplicates)
-
duplicateScopes
public Errors duplicateScopes(ScopeBinding existing, Class<? extends Annotation> annotationType, Scope scope)
-
voidProviderMethod
public Errors voidProviderMethod()
-
missingConstantValues
public Errors missingConstantValues()
-
duplicateBindingAnnotations
public Errors duplicateBindingAnnotations(Member member, Class<? extends Annotation> a, Class<? extends Annotation> b)
-
cannotInjectMethodWithTypeParameters
public Errors cannotInjectMethodWithTypeParameters(Method method)
-
duplicateScopeAnnotations
public Errors duplicateScopeAnnotations(Class<? extends Annotation> a, Class<? extends Annotation> b)
-
errorCheckingDuplicateBinding
public Errors errorCheckingDuplicateBinding(Key<?> key, Object source, Throwable t)
-
errorNotifyingTypeListener
public Errors errorNotifyingTypeListener(TypeListenerBinding listener, TypeLiteral<?> type, Throwable cause)
-
keyNotFullySpecified
public Errors keyNotFullySpecified(TypeLiteral<?> typeLiteral)
-
getMessagesFromThrowable
public static Collection<Message> getMessagesFromThrowable(Throwable throwable)
-
errorInUserCode
public Errors errorInUserCode(Throwable cause, String messageFormat, Object... arguments)
-
cannotInjectRawProvider
public Errors cannotInjectRawProvider()
-
cannotInjectRawMembersInjector
public Errors cannotInjectRawMembersInjector()
-
cannotInjectRawTypeLiteral
public Errors cannotInjectRawTypeLiteral()
-
throwCreationExceptionIfErrorsExist
public void throwCreationExceptionIfErrorsExist()
-
throwConfigurationExceptionIfErrorsExist
public void throwConfigurationExceptionIfErrorsExist()
-
throwProvisionExceptionIfErrorsExist
public void throwProvisionExceptionIfErrorsExist()
-
merge
public Errors merge(Collection<Message> messages)
-
merge
public Errors merge(InternalProvisionException ipe)
-
throwIfNewErrors
public void throwIfNewErrors(int expectedSize) throws ErrorsException
- Throws:
ErrorsException
-
toException
public ErrorsException toException()
-
hasErrors
public boolean hasErrors()
-
size
public int size()
-
convert
public static Object convert(Object o, ElementSource source)
-
-