Class InternalProvisionException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- com.google.inject.internal.InternalProvisionException
-
- All Implemented Interfaces:
java.io.Serializable
public final class InternalProvisionException extends java.lang.Exception
A checked exception for provisioning errors.This is the internal dual of
ProvisionException
, similar to the relationship betweenConfigurationException
andErrorsException
. This is useful for several reasons:- Since it is a checked exception, we get some assistance from the java compiler in ensuring that we correctly handle it everywhere. ProvisionException is unchecked.
- Since this is an internal package, we can add useful construction and mutation APIs that would be undesirable in a public supported API.
This exception will be thrown when errors are encountered during provisioning, ErrorsException will continue to be used for errors that are encountered during provisioning and both make use of the
Message
as the core model.NOTE: this object stores a list of messages but in the most common case the cardinality will be 1. The only time that multiple errors might be reported via this mechanism is when
errorInUserCode(com.google.inject.internal.ErrorId, java.lang.Throwable, java.lang.String, java.lang.Object...)
is called with an exception that holds multiple errors (like ProvisionException).- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private com.google.common.collect.ImmutableList<Message>
errors
private static java.util.logging.Logger
logger
private java.util.List<java.lang.Object>
sourcesToPrepend
private static java.util.Set<Dependency<?>>
warnedDependencies
-
Constructor Summary
Constructors Modifier Constructor Description (package private)
InternalProvisionException(Message error)
private
InternalProvisionException(java.lang.Iterable<Message> errors)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) InternalProvisionException
addSource(java.lang.Object source)
Prepends the givensource
to the stack of binding sources for the errors reported in this exception.static InternalProvisionException
cannotProxyClass(java.lang.Class<?> expectedType)
static InternalProvisionException
circularDependenciesDisabled(java.lang.Class<?> expectedType)
static InternalProvisionException
create(ErrorId errorId, java.lang.String format, java.lang.Object... arguments)
static InternalProvisionException
errorInjectingConstructor(java.lang.Throwable cause)
static InternalProvisionException
errorInjectingMethod(java.lang.Throwable cause)
static InternalProvisionException
errorInProvider(java.lang.Throwable cause)
static InternalProvisionException
errorInUserCode(ErrorId errorId, java.lang.Throwable cause, java.lang.String messageFormat, java.lang.Object... arguments)
static InternalProvisionException
errorInUserInjector(MembersInjector<?> listener, TypeLiteral<?> type, java.lang.RuntimeException cause)
static InternalProvisionException
errorNotifyingInjectionListener(InjectionListener<?> listener, TypeLiteral<?> type, java.lang.RuntimeException cause)
(package private) com.google.common.collect.ImmutableList<Message>
getErrors()
static InternalProvisionException
jitDisabled(Key<?> key)
(package private) static void
onNullInjectedIntoNonNullableDependency(java.lang.Object source, Dependency<?> dependency)
Returnsvalue
if it is non-null or allowed to be null.static InternalProvisionException
subtypeNotProvided(java.lang.Class<? extends javax.inject.Provider<?>> providerType, java.lang.Class<?> type)
ProvisionException
toProvisionException()
Returns this exception convered to a ProvisionException.
-
-
-
Field Detail
-
logger
private static final java.util.logging.Logger logger
-
warnedDependencies
private static final java.util.Set<Dependency<?>> warnedDependencies
-
sourcesToPrepend
private final java.util.List<java.lang.Object> sourcesToPrepend
-
errors
private final com.google.common.collect.ImmutableList<Message> errors
-
-
Method Detail
-
circularDependenciesDisabled
public static InternalProvisionException circularDependenciesDisabled(java.lang.Class<?> expectedType)
-
cannotProxyClass
public static InternalProvisionException cannotProxyClass(java.lang.Class<?> expectedType)
-
create
public static InternalProvisionException create(ErrorId errorId, java.lang.String format, java.lang.Object... arguments)
-
errorInUserCode
public static InternalProvisionException errorInUserCode(ErrorId errorId, java.lang.Throwable cause, java.lang.String messageFormat, java.lang.Object... arguments)
-
subtypeNotProvided
public static InternalProvisionException subtypeNotProvided(java.lang.Class<? extends javax.inject.Provider<?>> providerType, java.lang.Class<?> type)
-
errorInProvider
public static InternalProvisionException errorInProvider(java.lang.Throwable cause)
-
errorInjectingMethod
public static InternalProvisionException errorInjectingMethod(java.lang.Throwable cause)
-
errorInjectingConstructor
public static InternalProvisionException errorInjectingConstructor(java.lang.Throwable cause)
-
errorInUserInjector
public static InternalProvisionException errorInUserInjector(MembersInjector<?> listener, TypeLiteral<?> type, java.lang.RuntimeException cause)
-
jitDisabled
public static InternalProvisionException jitDisabled(Key<?> key)
-
errorNotifyingInjectionListener
public static InternalProvisionException errorNotifyingInjectionListener(InjectionListener<?> listener, TypeLiteral<?> type, java.lang.RuntimeException cause)
-
onNullInjectedIntoNonNullableDependency
static void onNullInjectedIntoNonNullableDependency(java.lang.Object source, Dependency<?> dependency) throws InternalProvisionException
Returnsvalue
if it is non-null or allowed to be null. Otherwise a message is added and anInternalProvisionException
is thrown.- Throws:
InternalProvisionException
-
addSource
InternalProvisionException addSource(java.lang.Object source)
Prepends the givensource
to the stack of binding sources for the errors reported in this exception.It is expected that this method is called as the exception propagates up the stack.
- Parameters:
source
-- Returns:
this
-
getErrors
com.google.common.collect.ImmutableList<Message> getErrors()
-
toProvisionException
public ProvisionException toProvisionException()
Returns this exception convered to a ProvisionException.
-
-