Skip to content

Commit

Permalink
Use an error tuple instead of throwing an exception
Browse files Browse the repository at this point in the history
  • Loading branch information
msantos committed Aug 11, 2011
1 parent 13340d6 commit 4154aac
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/wierl_monitor.erl
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,17 @@ open(Ifname) ->
open(Ifname, Flags) ->
case start_link(Ifname, Flags) of
{ok, Ref} ->
datalinktype(Ref),
open_1(Ref);
Error ->
Error
end.

open_1(Ref) ->
case datalinktype(Ref) of
ok ->
{ok, Ref};
Error ->
close(Ref),
Error
end.

Expand Down Expand Up @@ -256,7 +264,7 @@ datalinktype(Socket) ->
datalinktype(Socket, 200).

datalinktype(_Socket, 0) ->
throw({error,enetdown});
{error,enetdown};
datalinktype(Socket, N) ->
case read(Socket, 0) of
{error,eagain} ->
Expand Down

0 comments on commit 4154aac

Please sign in to comment.