Error Handling
The Streams package reports errors by throwing an exception or by using a return value in conjunction with status functions. Return values are used to report errors that occur on input stream functions that only partially succeed due to the stream reaching an end-of-file (eof). For instance, an input stream function that reads several elements might reach eof before being able to read all of the elements requested. In that case, the function puts the stream in both eof and fail mode, and returns the number of elements read. Output streams have three status member functions:
*isFail() indicates that the last operation carried out on the stream failed.
*isBad() indicates that an unrecoverable error occurred during the last operation carried out on the stream.
*isGood() returns true if both isFail() and isBad() are false.
Input streams also have these three status member functions, along with isEof(), which indicates that the stream cannot read any more data.