fix(bridge_v2 operations): better error message

This commit is contained in:
Kjell Winblad 2023-11-03 06:35:42 +01:00
parent 36640263ba
commit d14d0fbcb1
3 changed files with 9 additions and 10 deletions

View File

@ -1078,10 +1078,8 @@ call_operation(NodeOrAll, OperFunc, Args = [_Nodes, BridgeType, BridgeName]) ->
?NOT_FOUND(<<"Node not found: ", (atom_to_binary(Node))/binary>>);
{error, {unhealthy_target, Message}} ->
?BAD_REQUEST(Message);
{error, Reason} when not is_tuple(Reason); element(1, Reason) =/= 'exit' ->
?BAD_REQUEST(redact(Reason));
{error, Reason} ->
?BAD_REQUEST(Reason)
?BAD_REQUEST(redact(Reason))
end.
maybe_try_restart(all, start_bridges_to_all_nodes, Args) ->

View File

@ -490,8 +490,13 @@ connector_operation_helper_with_conf(
ok;
{error, Reason} ->
{error, Reason};
NonConnectedStatus ->
{error, NonConnectedStatus}
#{status := Status, error := Reason} ->
Msg = io_lib:format(
"Connector started but bridge (~s:~s) is not connected. "
"Bridge Status: ~p, Error: ~p",
[bin(BridgeV2Type), bin(Name), Status, Reason]
),
{error, iolist_to_binary(Msg)}
end
end.

View File

@ -606,12 +606,8 @@ call_operation(NodeOrAll, OperFunc, Args = [_Nodes, BridgeType, BridgeName]) ->
?SERVICE_UNAVAILABLE(<<"Bridge not found on remote node: ", BridgeId/binary>>);
{error, {node_not_found, Node}} ->
?NOT_FOUND(<<"Node not found: ", (atom_to_binary(Node))/binary>>);
{error, {unhealthy_target, Message}} ->
?BAD_REQUEST(Message);
{error, Reason} when not is_tuple(Reason); element(1, Reason) =/= 'exit' ->
?BAD_REQUEST(redact(Reason));
{error, Reason} ->
?BAD_REQUEST(Reason)
?BAD_REQUEST(redact(Reason))
end.
do_bpapi_call(all, Call, Args) ->