better error message for null setting values

This commit is contained in:
Mark Harrah 2012-09-18 13:22:40 -04:00
parent 37661c9576
commit 607824cc22
1 changed files with 5 additions and 1 deletions

View File

@ -88,7 +88,10 @@ abstract class EvaluateSettings[Scope]
private[this] val calledBy = new collection.mutable.ListBuffer[BindNode[_, T]]
override def toString = getClass.getName + " (state=" + state + ",blockedOn=" + blockedOn + ",calledBy=" + calledBy.size + ",blocking=" + blocking.size + "): " +
( (static.toSeq.flatMap { case (key, value) => if(value eq this) key.toString :: Nil else Nil }).headOption getOrElse "non-static")
keyString
private[this] def keyString =
(static.toSeq.flatMap { case (key, value) => if(value eq this) init.showFullKey(key) :: Nil else Nil }).headOption getOrElse "non-static"
final def get: T = synchronized {
assert(value != null, toString + " not evaluated")
@ -134,6 +137,7 @@ abstract class EvaluateSettings[Scope]
}
protected final def setValue(v: T) {
assert(state != Evaluated, "Already evaluated (trying to set value to " + v + "): " + toString)
if(v == null) error("Setting value cannot be null: " + keyString)
value = v
state = Evaluated
blocking foreach { _.unblocked() }