-
Notifications
You must be signed in to change notification settings - Fork 110
Open
Description
I have a gen server that calls other module with Websockex.send_frame, sometimes send_frame exits and parent gen server process exits too, so the only way I can handle it is to use try/catch :exit.
The spec of send_frame tells us that it returns result tuple, but it can exit in abnormal situation. I think there should be two variants: send_frame - never exits and returns :ok/:error, send_frame! - returns or exits.
@spec send_frame(client, frame) ::
:ok
| {:error,
%WebSockex.FrameEncodeError{}
| %WebSockex.ConnError{}
| %WebSockex.NotConnectedError{}
| %WebSockex.InvalidFrameError{}}
| none
def send_frame(client, _) when client == self() do
raise %WebSockex.CallingSelfError{function: :send_frame}
end
def send_frame(client, frame) do
try do
{:ok, res} = :gen.call(client, :"$websockex_send", frame)
res
catch
_, reason ->
exit({reason, {__MODULE__, :call, [client, frame]}})
end
endcanselcik and mgwidmann
Metadata
Metadata
Assignees
Labels
No labels