I know that general or "across the board" exception handling is a big no-no, however I believe that it is okay in this case.
Consider some custom wrapper around BinaryWriter/BinaryReader operations. (Yes, I know of .NET serialization) In all of the methods in this class, there would be the potential to have certain exceptions, like passing in a byte[] that is too short for the data you are trying to read out of it or attempting to read an incorrect type.
So there are all these different methods for writing/reading data and I would like to handle all instances of certain exceptions thrown in this class in a certain way. For example, returning an error state or setting a certain flag whenever an EndOfStreamException
is thrown.
Is there a clean/good way to do this short of throwing a try/catch around each read/write operation? Or is this still a big no-no because users of the library should just try-catch the calls to the class themselves?