replace errno with errcodes