Set errno on failures