Class 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
    • Constructor Detail

      • Errors

        public Errors()
      • Errors

        public Errors​(Object source)
    • Method Detail

      • withSource

        public Errors withSource​(Object source)
        Returns an instance that uses source as a reference point for newly added errors.
      • 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:
        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.
      • jitDisabled

        public Errors jitDisabled​(Key<?> key)
      • jitDisabledInParent

        public Errors jitDisabledInParent​(Key<?> key)
      • bindingToProvider

        public Errors bindingToProvider()
      • notASubtype

        public Errors notASubtype​(Class<?> implementationType,
                                  Class<?> type)
      • 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)
      • cannotBindToGuiceType

        public Errors cannotBindToGuiceType​(String simpleName)
      • misplacedBindingAnnotation

        public Errors misplacedBindingAnnotation​(Member member,
                                                 Annotation bindingAnnotation)
      • tooManyConstructors

        public Errors tooManyConstructors​(Class<?> implementation)
      • duplicateMapKey

        public <K,​V> Errors duplicateMapKey​(Key<Map<K,​V>> mapKey,
                                                  com.google.common.collect.Multimap<K,​Binding<V>> duplicates)
      • voidProviderMethod

        public Errors voidProviderMethod()
      • missingConstantValues

        public Errors missingConstantValues()
      • cannotInjectInnerClass

        public Errors cannotInjectInnerClass​(Class<?> type)
      • staticInjectionOnInterface

        public Errors staticInjectionOnInterface​(Class<?> clazz)
      • cannotInjectFinalField

        public Errors cannotInjectFinalField​(Field field)
      • cannotInjectAbstractMethod

        public Errors cannotInjectAbstractMethod​(Method method)
      • cannotInjectMethodWithTypeParameters

        public Errors cannotInjectMethodWithTypeParameters​(Method method)
      • recursiveBinding

        public Errors recursiveBinding​(Key<?> key,
                                       Key<?> linkedKey)
      • bindingAlreadySet

        public Errors bindingAlreadySet​(Key<?> key,
                                        Object source)
      • jitBindingAlreadySet

        public Errors jitBindingAlreadySet​(Key<?> key)
      • childBindingAlreadySet

        public Errors childBindingAlreadySet​(Key<?> key,
                                             Set<Object> sources)
      • errorCheckingDuplicateBinding

        public Errors errorCheckingDuplicateBinding​(Key<?> key,
                                                    Object source,
                                                    Throwable t)
      • exposedButNotBound

        public Errors exposedButNotBound​(Key<?> key)
      • keyNotFullySpecified

        public Errors keyNotFullySpecified​(TypeLiteral<?> typeLiteral)
      • cannotInjectRawProvider

        public Errors cannotInjectRawProvider()
      • cannotInjectRawMembersInjector

        public Errors cannotInjectRawMembersInjector()
      • cannotInjectTypeLiteralOf

        public Errors cannotInjectTypeLiteralOf​(Type unsupportedType)
      • cannotInjectRawTypeLiteral

        public Errors cannotInjectRawTypeLiteral()
      • throwCreationExceptionIfErrorsExist

        public void throwCreationExceptionIfErrorsExist()
      • throwConfigurationExceptionIfErrorsExist

        public void throwConfigurationExceptionIfErrorsExist()
      • throwProvisionExceptionIfErrorsExist

        public void throwProvisionExceptionIfErrorsExist()
      • hasErrors

        public boolean hasErrors()
      • size

        public int size()
      • formatSource

        public static void formatSource​(Formatter formatter,
                                        Object source)