diff options
author | Eric <[email protected]> | 2012-12-26 20:18:18 -0500 |
---|---|---|
committer | Eric <[email protected]> | 2012-12-26 20:21:02 -0500 |
commit | 713b954082068456db93e2c5f661169550e29fda (patch) | |
tree | 6a594fd1749d720ca6aa552e6472b1bfcb623972 /src/rcl_util.erl | |
parent | 2eed239f63a5ae64e99522142a262f0af67425a0 (diff) | |
download | relx-713b954082068456db93e2c5f661169550e29fda.tar.gz relx-713b954082068456db93e2c5f661169550e29fda.tar.bz2 relx-713b954082068456db93e2c5f661169550e29fda.zip |
provide utility functions for error decomposition
Diffstat (limited to 'src/rcl_util.erl')
-rw-r--r-- | src/rcl_util.erl | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/rcl_util.erl b/src/rcl_util.erl index f6427ae..f89ba73 100644 --- a/src/rcl_util.erl +++ b/src/rcl_util.erl @@ -23,6 +23,8 @@ -export([mkdir_p/1, to_binary/1, + is_error/1, + error_reason/1, indent/1]). -define(ONE_LEVEL_INDENT, " "). @@ -55,6 +57,18 @@ to_binary(String) when erlang:is_list(String) -> to_binary(Bin) when erlang:is_binary(Bin) -> Bin. +%% @doc get the reason for a particular relcool error +-spec error_reason(relcool:error()) -> any(). +error_reason({error, {_, Reason}}) -> + Reason. +%% @doc check to see if the value is a relcool error +-spec is_error(relcool:error() | any()) -> boolean(). +is_error({error, _}) -> + true; +is_error(_) -> + false. + + %%%=================================================================== %%% Test Functions |