return proper error code