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
|
checkReceiveTimeout
|
||||||
if (system.settings.DebugLifecycle) system.eventStream.publish(Debug(self.path.toString, clazz(created), "started (" + created + ")"))
|
if (system.settings.DebugLifecycle) system.eventStream.publish(Debug(self.path.toString, clazz(created), "started (" + created + ")"))
|
||||||
} catch {
|
} 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.
|
* Scala API.
|
||||||
*/
|
*/
|
||||||
def apply[T <: Actor: ClassManifest]: Props =
|
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
|
* 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.
|
* of the supplied class using the default constructor.
|
||||||
*/
|
*/
|
||||||
def apply(actorClass: Class[_ <: Actor]): Props =
|
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
|
* 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 =
|
def apply(behavior: ActorContext ⇒ Actor.Receive): Props =
|
||||||
apply(new Actor { def receive = behavior(context) })
|
apply(new Actor { def receive = behavior(context) })
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue