Skip to content

Commit 3dabe01

Browse files
committed
Merge pull request #39 from basho/jrd/cuttlefish-errors
Track pending changes to cuttlefish error handling Reviewed-by: andrewjstone
2 parents e9b150a + 373a62e commit 3dabe01

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/clique_error.erl

+12-1
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,12 @@ format(_Cmd, {error, {too_many_equal_signs, Arg}}) ->
6868
format(_Cmd, {error, {invalid_config_keys, Invalid}}) ->
6969
status(io_lib:format("Invalid config keys: ~ts", [Invalid]));
7070
format(_Cmd, {error, {invalid_config, {error, [_H|_T]=Msgs}}}) ->
71-
%% Cuttlefish deeply nested errors
71+
%% Cuttlefish deeply nested errors (original cuttlefish)
7272
status(string:join(lists:map(fun({error, Msg}) -> Msg end,
7373
Msgs), "\n"));
74+
format(_Cmd, {error, {invalid_config, {errorlist, Errors}}}) ->
75+
%% Cuttlefish deeply nested errors (new cuttlefish error scheme)
76+
status(string:join(lists:map(fun error_map/1, Errors), "\n"));
7477
format(_Cmd, {error, {invalid_config, Msg}}) ->
7578
status(io_lib:format("Invalid configuration: ~p~n", [Msg]));
7679
format(_Cmd, {error, {rpc_process_down, Node}}) ->
@@ -85,3 +88,11 @@ format(_Cmd, {error, bad_node}) ->
8588
-spec status(string()) -> status().
8689
status(Str) ->
8790
[clique_status:alert([clique_status:text(Str)])].
91+
92+
%% Here we can override cuttlefish error messages to make them more
93+
%% useful in an interactive context
94+
-spec error_map(cuttlefish_error:error()) -> iolist().
95+
error_map({error, {unknown_variable, Variable}}) ->
96+
io_lib:format("Unknown variable: ~ts", [Variable]);
97+
error_map({error, ErrorTerm}) ->
98+
cuttlefish_error:xlate(ErrorTerm).

0 commit comments

Comments
 (0)