Unify error logic