jaspervdj / websockets

A Haskell library for creating WebSocket-capable servers
http://jaspervdj.be/websockets
BSD 3-Clause "New" or "Revised" License
407 stars 114 forks source link

Exception always raised even with safe shutdown? #157

Open centromere opened 7 years ago

centromere commented 7 years ago

For sendClose:

This exception is when you can finally consider the connection closed.

If I am closing the connection properly, why should an exception ever be raised? Shouldn't exceptions only be raised for exceptional circumstances?

jaspervdj commented 6 years ago

I think this is the best way to have a "uniform" way of exiting out of calls like receive. Additionally, it works very well functions like bracket from Control.Exception.

The alternative would be to have receive return the close message, but that:

  1. Is a breaking change (which is hard to argue for)
  2. Breaks the idea that the library takes care of "control messages" (open, close, ping, continue...)