Ticket #3517 (new bug)

Opened 4 years ago

Last modified 9 months ago

GHC has lots of extra hidden IOErrorType values

Reported by: duncan Owned by:
Priority: low Milestone: 7.6.2
Component: libraries/base Version:
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

I was fixing bytestring's hGet (see #3514) and I discover that I cannot produce the same exception as System.IO.hGet does in the same circumstance.

There are two problems:

One is that GHC's internal IOError has more information than one can set via System.IO.Error.mkIOError. In particular it has a function name.

The other is that System.IO.hGet throws an InvalidArgument IOErrorType, however this is not exported and there are no smart constructors or testers for this error type. This is problematic for two reasons, portable code cannot generate these error types to mirror the standard System.IO and secondly no code can actually catch these errors except in a general "catch all" style because they cannot be distinguished from each other.

Code that wants to mirror System.IO (like bytestring or utf8-string) has to import GHC.IO.Exception and use cpp to do it differently for hugs and nhc.

Change History

Changed 4 years ago by igloo

  • difficulty set to Unknown
  • milestone set to 6.14.1

Ideally we would be moving to an extensible exception hierarchy, of course.

Changed 3 years ago by duncan

  • failure set to None/Unknown

I've run into this again. Distribution.TestSuite needs access to IOErrorType(Interrupted) because it needs to catch all errors that a test might throw (so it can report how it failed) but we do not want to catch control-C, so we have to test for Interrupted and rethrow in that case. It's not reasonable that doing so means we have to write non-portable code.

So what is the solution? That we make IOException a subclass of Exception with the current fields that the IOException record has, then make all the various IOErrorTypes into new types that are instances of the new IOException class?

Changed 3 years ago by igloo

  • milestone changed from 7.0.1 to 7.0.2

Changed 2 years ago by igloo

  • milestone changed from 7.0.2 to 7.2.1

Changed 21 months ago by igloo

  • milestone changed from 7.2.1 to 7.4.1

Changed 17 months ago by igloo

  • priority changed from normal to low
  • milestone changed from 7.4.1 to 7.6.1

Changed 9 months ago by igloo

  • milestone changed from 7.6.1 to 7.6.2
Note: See TracTickets for help on using tickets.