[Haskell-cafe] An exceptional exception

Andrew Coppin andrewcoppin at btinternet.com
Fri Nov 9 15:01:42 EST 2007

Well, my problems have now multiplied beyong belief!

Allow me to summerise:

1. There exists an I/O exception called "invalid parameter", which is 
not detectable with any of the 8 predicates. (Isn't this what "illegal 
operation" is supposed to be for? A general catch-all?)

2. Attempting to open an invalid filename yields the undetectable 
"invalid parameter" exception (rather than, say, illegal operation).

3. Attempting to read a directory with an invalid name does the same.

3. Attempting to open a *file* you don't have permission for yields 
"permission error", as expected. However, attempting to read a 
*directory* yields... invalid parameter again. (Thus, even if this 
exception were detectable, there's no way to tell the difference between 
a permission error and a malformed filename.)

4. Not actually related to exceptions, but doesDirectoryExist "C:\" 
yields False. (Even though getDirectoryContents "C:\" yields the correct 
result.) So I can't even use that to filter out invalid directory names.

Aaaarrrgh! >_<

Clearly, making my program give the user meaningful error messages is 
going to be very hard - unless I resort to trying to *parse* the output 
of the Show instance for IOError...

Does anybody have any helpful hints for me at this point?

More information about the Haskell-Cafe mailing list