From 713b954082068456db93e2c5f661169550e29fda Mon Sep 17 00:00:00 2001 From: Eric Date: Wed, 26 Dec 2012 20:18:18 -0500 Subject: provide utility functions for error decomposition --- src/rcl_util.erl | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/rcl_util.erl') 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 -- cgit v1.2.3