Check a return value for error.