Fixed error detection

$code was null on success on Linux CentOS 5 with jre7