remove old style catches from the library
This removes the old style catches and replaces them with try/catch. It seems to make the code much clearer and its certainly less failure prone.
This commit is contained in:
parent
8dda138814
commit
eecbb26a2d
2 changed files with 6 additions and 5 deletions
|
@ -97,13 +97,14 @@ remove(Path) ->
|
||||||
%% @doc indicates witha boolean if the path supplied refers to symlink.
|
%% @doc indicates witha boolean if the path supplied refers to symlink.
|
||||||
-spec is_symlink(path()) -> boolean().
|
-spec is_symlink(path()) -> boolean().
|
||||||
is_symlink(Path) ->
|
is_symlink(Path) ->
|
||||||
case catch file:read_link_info(Path) of
|
case file:read_link_info(Path) of
|
||||||
{ok, #file_info{type = symlink}} ->
|
{ok, #file_info{type = symlink}} ->
|
||||||
true;
|
true;
|
||||||
_ ->
|
_ ->
|
||||||
false
|
false
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
||||||
%% @doc make a unique temorory directory. Similar function to BSD stdlib
|
%% @doc make a unique temorory directory. Similar function to BSD stdlib
|
||||||
%% function of the same name.
|
%% function of the same name.
|
||||||
-spec mkdtemp() -> TmpDirPath::path().
|
-spec mkdtemp() -> TmpDirPath::path().
|
||||||
|
|
|
@ -88,10 +88,10 @@ compare_toks2(_ToksA, _ToksB) ->
|
||||||
|
|
||||||
-spec to_int(string()) -> integer().
|
-spec to_int(string()) -> integer().
|
||||||
to_int(String) ->
|
to_int(String) ->
|
||||||
case catch list_to_integer(String) of
|
try
|
||||||
Integer when is_integer(Integer) ->
|
list_to_integer(String)
|
||||||
Integer;
|
catch
|
||||||
_ ->
|
error:badarg ->
|
||||||
throw(invalid_semver_string)
|
throw(invalid_semver_string)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue