Enriching errors in the "network" library

Kazu Yamamoto (山本和彦) via Haskell-Cafe <[email protected]> Wed, 01 Apr 2026 09:02:21 +0900 (JST)
Newsgroups gmane.comp.lang.haskell.cafe
Message-ID <[email protected]>
Hi all,

For many years, users of the "network" library have been suffered from
poor error handling. For example, the "bind" function displays an
error message like the following, but it doesn't tell you which port
you were trying to bind to.

     Network.Socket.bind: resource busy (Address already in use)

I am working to improve this situation. The error message becomes as
follows:

     Network.Socket.bind: resource busy (Address already in use 
[EADDRINUSE] <socket: 13> [::1]:53)

If you're interested, please join the discussion:

     https://github.com/haskell/network/pull/610

P.S.

In my opinion, Show IOException should display errno. Why doesn't it
display?

instance Show IOException where
     showsPrec p (IOError hdl iot loc s _errno fn) =
       (case fn of
          Nothing -> case hdl of
                         Nothing -> id
                         Just h  -> showsPrec p h . showString ": "
          Just name -> showString name . showString ": ") .
       (case loc of
          "" -> id
          _  -> showString loc . showString ": ") .
       showsPrec p iot .
       (case s of
          "" -> id
          _  -> showString " (" . showString s . showString ")")

--Kazu


_______________________________________________
Haskell-Cafe mailing list -- [email protected]
To (un)subscribe, modify options or view archives go to:
Only members subscribed via the mailman list are allowed to post.