feat: allow specifying more helpful messages for unhealthy targets
This commit is contained in:
parent
30d78aaac2
commit
c4fc0e767e
|
@ -1000,6 +1000,8 @@ call_operation(NodeOrAll, OperFunc, Args = [_Nodes, BridgeType, BridgeName]) ->
|
||||||
?SERVICE_UNAVAILABLE(<<"Bridge not found on remote node: ", BridgeId/binary>>);
|
?SERVICE_UNAVAILABLE(<<"Bridge not found on remote node: ", BridgeId/binary>>);
|
||||||
{error, {node_not_found, Node}} ->
|
{error, {node_not_found, Node}} ->
|
||||||
?NOT_FOUND(<<"Node not found: ", (atom_to_binary(Node))/binary>>);
|
?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' ->
|
{error, Reason} when not is_tuple(Reason); element(1, Reason) =/= 'exit' ->
|
||||||
?BAD_REQUEST(Reason)
|
?BAD_REQUEST(Reason)
|
||||||
end.
|
end.
|
||||||
|
|
|
@ -282,6 +282,8 @@ query(ResId, Request, Opts) ->
|
||||||
case {QM, Error} of
|
case {QM, Error} of
|
||||||
{_, unhealthy_target} ->
|
{_, unhealthy_target} ->
|
||||||
?RESOURCE_ERROR(unhealthy_target, "unhealthy target");
|
?RESOURCE_ERROR(unhealthy_target, "unhealthy target");
|
||||||
|
{_, {unhealthy_target, _Message}} ->
|
||||||
|
?RESOURCE_ERROR(unhealthy_target, "unhealthy target");
|
||||||
{simple_async, _} ->
|
{simple_async, _} ->
|
||||||
%% TODO(5.1.1): pass Resource instead of ResId to simple APIs
|
%% TODO(5.1.1): pass Resource instead of ResId to simple APIs
|
||||||
%% so the buffer worker does not need to lookup the cache again
|
%% so the buffer worker does not need to lookup the cache again
|
||||||
|
|
|
@ -642,6 +642,7 @@ status_to_error(_) ->
|
||||||
{error, undefined}.
|
{error, undefined}.
|
||||||
|
|
||||||
%% Compatibility
|
%% Compatibility
|
||||||
|
external_error({error, {unhealthy_target, Message}}) -> Message;
|
||||||
external_error({error, Reason}) -> Reason;
|
external_error({error, Reason}) -> Reason;
|
||||||
external_error(Other) -> Other.
|
external_error(Other) -> Other.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue