public final class Errors extends Object implements Serializable
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.
public Errors()
public Errors(Object source)
public Errors withSource(Object source)
source
as a reference point for newly added errors.public Errors missingImplementation(Key key)
Guice.createInjector(new AbstractModule() {
public void configure() {
bind(Runnable.class);
}
}
...and at provide-time errors:
Guice.createInjector().getInstance(Runnable.class);
Otherwise we need to know who's calling when resolving a just-in-time
binding, which makes things unnecessarily complex.public Errors converterReturnedNull(String stringValue, Object source, TypeLiteral<?> type, TypeConverterBinding typeConverterBinding)
public Errors conversionTypeError(String stringValue, Object source, TypeLiteral<?> type, TypeConverterBinding typeConverterBinding, Object converted)
public Errors conversionError(String stringValue, Object source, TypeLiteral<?> type, TypeConverterBinding typeConverterBinding, RuntimeException cause)
public Errors ambiguousTypeConversion(String stringValue, Object source, TypeLiteral<?> type, TypeConverterBinding a, TypeConverterBinding b)
public Errors bindingToProvider()
public Errors subtypeNotProvided(Class<? extends javax.inject.Provider<?>> providerType, Class<?> type)
public Errors recursiveImplementationType()
public Errors recursiveProviderType()
public Errors missingRuntimeRetention(Class<? extends Annotation> annotation)
public Errors missingScopeAnnotation(Class<? extends Annotation> annotation)
public Errors optionalConstructor(Constructor constructor)
public Errors scopeNotFound(Class<? extends Annotation> scopeAnnotation)
public Errors scopeAnnotationOnAbstractType(Class<? extends Annotation> scopeAnnotation, Class<?> type, Object source)
public Errors misplacedBindingAnnotation(Member member, Annotation bindingAnnotation)
public Errors constructorNotDefinedByType(Constructor<?> constructor, TypeLiteral<?> type)
public Errors duplicateScopes(ScopeBinding existing, Class<? extends Annotation> annotationType, Scope scope)
public Errors voidProviderMethod()
public Errors missingConstantValues()
public Errors duplicateBindingAnnotations(Member member, Class<? extends Annotation> a, Class<? extends Annotation> b)
public Errors cannotInjectMethodWithTypeParameters(Method method)
public Errors duplicateScopeAnnotations(Class<? extends Annotation> a, Class<? extends Annotation> b)
public Errors recursiveBinding()
public Errors errorCheckingDuplicateBinding(Key<?> key, Object source, Throwable t)
public Errors errorNotifyingTypeListener(TypeListenerBinding listener, TypeLiteral<?> type, Throwable cause)
public Errors errorInUserInjector(MembersInjector<?> listener, TypeLiteral<?> type, RuntimeException cause)
public Errors errorNotifyingInjectionListener(InjectionListener<?> listener, TypeLiteral<?> type, RuntimeException cause)
public Errors keyNotFullySpecified(TypeLiteral<?> typeLiteral)
public static Collection<Message> getMessagesFromThrowable(Throwable throwable)
public Errors errorInUserCode(Throwable cause, String messageFormat, Object... arguments)
public Errors cannotInjectRawProvider()
public Errors cannotInjectRawMembersInjector()
public Errors cannotInjectRawTypeLiteral()
public void throwCreationExceptionIfErrorsExist()
public void throwConfigurationExceptionIfErrorsExist()
public void throwProvisionExceptionIfErrorsExist()
public Errors merge(Collection<Message> messages)
public void throwIfNewErrors(int expectedSize) throws ErrorsException
ErrorsException
public ErrorsException toException()
public boolean hasErrors()
public static String format(String heading, Collection<Message> errorMessages)
public <T> T checkForNull(T value, Object source, Dependency<?> dependency) throws ErrorsException
value
if it is non-null or allowed to be null. Otherwise a message is added and
an ErrorsException
is thrown.ErrorsException
public static Throwable getOnlyCause(Collection<Message> messages)
messages
. If there are
zero or multiple messages with causes, null is returned.public int size()
public static Object convert(Object o, ElementSource source)
public static void formatSource(Formatter formatter, Object source, ElementSource elementSource)
public static void formatInjectionPoint(Formatter formatter, Dependency<?> dependency, InjectionPoint injectionPoint, ElementSource elementSource)
Copyright © 2006-2016 Google, Inc.. All Rights Reserved.