davebryson/erlang_websocket — Issue #4: websocket_client: how can I detect if server is down while connecting?
Author: goberman
Created: 2012-01-11 15:18:37+00:00
State: open

If I call websocket_client:start(Host, Port, ?MODULE), but server is not running, the API generates exception:
** exception exit: {badmatch,{error,econnrefused}}
in function websocket_client:init/1 (d:/DAVEBR~1/src/websocket_client.erl, line 46)
in call from gen_server:init_it/6 (gen_server.erl, line 297)
in call from proc_lib:init_p_do_apply/3 (proc_lib.erl, line 227)

It would be nice to have some callback invoked when connection cannot be established.
Is there any way to catch this exception in my code?
Thanks