errno support

based on #42 issue , cc @CindyLinz