MDL-37374 questions: use property_exists rather than isset

$a->field = null; isset($a->field) returns false, which is typical PHP.
I also improve the error handling a bit.