Fix object error check
Merge pull request #278 from brunocoelho/fix_err_check

Fix object error check