Error handling based on errno

Add semantic meaning to every early return using errno and the values it provides