Check for $error['code'] instead of $error['type']