Better error handling for getting current working directory

Also unifies the style for the other Errno handling.