Simple refactoring to the capture-errno function.