Improve the error handling for the I/O class.