Skip to content

Enrich error#610

Open
kazu-yamamoto wants to merge 1 commit intohaskell:masterfrom
kazu-yamamoto:enrich-error
Open

Enrich error#610
kazu-yamamoto wants to merge 1 commit intohaskell:masterfrom
kazu-yamamoto:enrich-error

Conversation

@kazu-yamamoto
Copy link
Copy Markdown
Collaborator

Trying to implement #609.

@khibino This is PoC. The error of bind is change from:

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

to

Network.Socket.bind: resource busy (Address already in use (EADDRINUSE) <socket: 14>)

The current problem is there are no way to show SocketAddress sa.

@kazu-yamamoto
Copy link
Copy Markdown
Collaborator Author

Breaking backward compatibility but just adding Show to bind:

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

@kazu-yamamoto
Copy link
Copy Markdown
Collaborator Author

@khibino I guess this PR is ready for reviewing.
Backward compatibility is kept, yay!

@vdukhovni
Copy link
Copy Markdown

Breaking backward compatibility but just adding Show to bind:

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

Adding the associated address for connect, bind, sendTo, ... is quite useful.
Perhaps also for already connected TCP sockets, when a connection breaks, or I/O times out, ... a getpeername() may be able to recover the peer address, so it can be reported.

But, FWIW, I am not sure that reporting the socket file descriptor number is useful, it does not tell the user much. If the user could "decorate" the socket with custom info about its purpose/role in the application to be reported on error, that'd work better, but may not be warranted.

@kazu-yamamoto
Copy link
Copy Markdown
Collaborator Author

Labeling sockets sounds a good idea.

@sjakobi
Copy link
Copy Markdown
Member

sjakobi commented Apr 1, 2026

I saw your message on Haskell Cafe:

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

I don't know why the instance is this way, but the problem has been noticed before. See https://gitlab.haskell.org/ghc/ghc/-/issues/16048.

@kazu-yamamoto
Copy link
Copy Markdown
Collaborator Author

An accepted socket (in the server side) is now labeled as:

<socket: 14 [::1]:58926>

@kazu-yamamoto
Copy link
Copy Markdown
Collaborator Author

@vdukhovni I fully re-implemented this scheme.
Now we have labelSocket and socketLabel
A connected socket is labeled as "sock 13 [::1]:8080 [::1]:60708", for instance.

@kazu-yamamoto
Copy link
Copy Markdown
Collaborator Author

I should merge #602 first then this PR next.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants