summaryrefslogtreecommitdiff
path: root/src/rabbit_control.erl
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2011-11-25 10:08:23 +0000
committerSimon MacMullen <simon@rabbitmq.com>2011-11-25 10:08:23 +0000
commitbaabb9a307a6c5a55ea5c2bd163431449d7c0aa4 (patch)
treea7a6046babae32e491526600f3ea8836c4061fcf /src/rabbit_control.erl
parent8361f7e9c7542d1468a26a5b80b4ff9ecb6bacb1 (diff)
downloadrabbitmq-server-baabb9a307a6c5a55ea5c2bd163431449d7c0aa4.tar.gz
Still nicer error handling inspired by lib:eval_str/1.bug24593
Diffstat (limited to 'src/rabbit_control.erl')
-rw-r--r--src/rabbit_control.erl14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/rabbit_control.erl b/src/rabbit_control.erl
index 6fa25ba6..20486af5 100644
--- a/src/rabbit_control.erl
+++ b/src/rabbit_control.erl
@@ -98,6 +98,9 @@ start() ->
{error, Reason} ->
print_error("~p", [Reason]),
rabbit_misc:quit(2);
+ {error_string, Reason} ->
+ print_error("~s", [Reason]),
+ rabbit_misc:quit(2);
{badrpc, {'EXIT', Reason}} ->
print_error("~p", [Reason]),
rabbit_misc:quit(2);
@@ -379,11 +382,11 @@ action(eval, Node, [Expr], _Opts, _Inform) ->
Node, erl_eval, exprs, [Parsed, []]),
io:format("~p~n", [Value]),
ok;
- {error, {1, erl_parse, Err}} ->
- {error, Err}
+ {error, E} ->
+ {error_string, format_parse_error(E)}
end;
- {error, {1, erl_scan, E}, _} ->
- {error, ["scan error: ", E]}
+ {error, E, _} ->
+ {error_string, format_parse_error(E)}
end.
%%----------------------------------------------------------------------------
@@ -459,6 +462,9 @@ system(Cmd) ->
escape_quotes(Cmd) ->
lists:flatten(lists:map(fun ($') -> "'\\''"; (Ch) -> Ch end, Cmd)).
+format_parse_error({_Line, Mod, Err}) ->
+ lists:flatten(Mod:format_error(Err)).
+
%%----------------------------------------------------------------------------
default_if_empty(List, Default) when is_list(List) ->