set error code on failure