net/server: improve error for truthy handler and type :datagram#1615
net/server: improve error for truthy handler and type :datagram#1615bakpakin merged 1 commit intojanet-lang:masterfrom
Conversation
fe2d454 to
92fc152
Compare
|
Thanks for the PR! If Do we want to handle things a bit differently in the Right now it looks to me like the (case type
:stream (if handler
(ev/go (fn [] (net/accept-loop s handler))))
:datagram (if handler
(error "handler not supported for :datagram servers")))May be we can use |
92fc152 to
953efc4
Compare
|
Good catch @sogaiu! I think the |
953efc4 to
0f04372
Compare
|
The newest revision avoids using |
|
Just a quick note. Don't know if it would be an improvement, but perhaps an alternative to this expression: (if (and (= type :datagram) handler)
(error "handler not supported for :datagram servers"))might be to use Will think on it a bit more. |
Since it is invalid to call accept on a datagram socket, net/server always errors if handler is truthy and type is :datagram. Add an assert to give a better error message in this case and clarify the documentation. References: janet-lang#1614
0f04372 to
f974c06
Compare
|
I think I do like the assert a bit more, perhaps this is finally the final version of this patch :) |
|
LGTM |
Since it is invalid to call accept on a datagram socket, net/server always errors if handler is truthy and type is :datagram.
Tweak the implementation to give a better error message in this case.
References: #1614