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 ethod'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, MatcherAndConverter matchingConverter)
public Errors conversionTypeError(String stringValue, Object source, TypeLiteral<?> type, MatcherAndConverter matchingConverter, Object converted)
public Errors conversionError(String stringValue, Object source, TypeLiteral<?> type, MatcherAndConverter matchingConverter, RuntimeException cause)
public Errors ambiguousTypeConversion(String stringValue, Object source, TypeLiteral<?> type, MatcherAndConverter a, MatcherAndConverter b)
public Errors bindingToProvider()
public Errors subtypeNotProvided(Class<? extends Provider<?>> providerType, Class<?> type)
public Errors recursiveImplementationType()
public Errors recursiveProviderType()
public Errors missingScopeAnnotation()
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 duplicateScopes(Scope 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 duplicateScopeAnnotations(Class<? extends Annotation> a, Class<? extends Annotation> b)
public Errors recursiveBinding()
public Errors errorNotifyingTypeListener(TypeListenerBinding listener, TypeLiteral<?> type, Throwable cause)
public Errors errorInProvider(RuntimeException runtimeException)
public Errors errorInUserInjector(MembersInjector<?> listener, TypeLiteral<?> type, RuntimeException cause)
public Errors errorNotifyingInjectionListener(InjectionListener<?> listener, TypeLiteral<?> type, RuntimeException cause)
public void exposedButNotBound(Key<?> key)
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 Errors cannotSatisfyCircularDependency(Class<?> expectedType)
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 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 void formatInjectionPoint(Formatter formatter, Dependency<?> dependency, InjectionPoint injectionPoint)
Copyright © 2009–2016. All rights reserved.