Better error message for when val initialization errors occur (properties, tasks,...)

This commit is contained in:
Mark Harrah 2009-10-21 19:06:33 -04:00
parent 15b9c15e6a
commit edbdc7d7bc
1 changed files with 2 additions and 1 deletions

View File

@ -44,7 +44,7 @@ object ReflectUtilities
for(field <- correspondingFields.get(method.getName) if field.getType == method.getReturnType)
{
val value = method.invoke(self).asInstanceOf[T]
assume(value != null, "val " + method.getName + " was null")
if(value == null) throw new UninitializedVal(method.getName, method.getDeclaringClass.getName)
mappings(method.getName) = value
}
}
@ -54,3 +54,4 @@ object ReflectUtilities
def allVals[T](self: AnyRef)(implicit mt: scala.reflect.Manifest[T]): Map[String, T] =
allValsC(self, mt.erasure).asInstanceOf[Map[String,T]]
}
final class UninitializedVal(val valName: String, val className: String) extends RuntimeException("val " + valName + " in class " + className + " was null.\nThis is probably an initialization problem and a 'lazy val' should be used.")