Clarifying the error message given when there's an InstantiationException during create
This commit is contained in:
parent
e6513bcb67
commit
b9a4e3a7c4
2 changed files with 10 additions and 4 deletions
|
|
@ -509,7 +509,14 @@ private[akka] class ActorCell(
|
|||
checkReceiveTimeout
|
||||
if (system.settings.DebugLifecycle) system.eventStream.publish(Debug(self.path.toString, clazz(created), "started (" + created + ")"))
|
||||
} catch {
|
||||
case NonFatal(e) ⇒ throw ActorInitializationException(self, "exception during creation", e)
|
||||
case NonFatal(i: InstantiationException) ⇒
|
||||
throw ActorInitializationException(self,
|
||||
"""exception during creation, this problem is likely to occur because the class of the Actor you tried to create is either,
|
||||
a non-static inner class (in which case make it a static inner class or use Props(new ...) or Props( new UntypedActorFactory ... )
|
||||
or is missing an appropriate, reachable no-args constructor.
|
||||
""", i)
|
||||
case NonFatal(e) ⇒
|
||||
throw ActorInitializationException(self, "exception during creation", e)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,14 +43,14 @@ object Props {
|
|||
* Scala API.
|
||||
*/
|
||||
def apply[T <: Actor: ClassManifest]: Props =
|
||||
default.withCreator(implicitly[ClassManifest[T]].erasure.asInstanceOf[Class[_ <: Actor]].newInstance)
|
||||
default.withCreator(implicitly[ClassManifest[T]].erasure.asInstanceOf[Class[_ <: Actor]])
|
||||
|
||||
/**
|
||||
* Returns a Props that has default values except for "creator" which will be a function that creates an instance
|
||||
* of the supplied class using the default constructor.
|
||||
*/
|
||||
def apply(actorClass: Class[_ <: Actor]): Props =
|
||||
default.withCreator(actorClass.newInstance)
|
||||
default.withCreator(actorClass)
|
||||
|
||||
/**
|
||||
* Returns a Props that has default values except for "creator" which will be a function that creates an instance
|
||||
|
|
@ -70,7 +70,6 @@ object Props {
|
|||
|
||||
def apply(behavior: ActorContext ⇒ Actor.Receive): Props =
|
||||
apply(new Actor { def receive = behavior(context) })
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue