ED-145: Handle exception ProvisionTermSetUndefined (#565)

This commit is contained in:
Boris 2021-05-13 16:02:22 +03:00 committed by GitHub
parent 3012a02820
commit 744d95f5e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 18 deletions

View File

@ -3,6 +3,7 @@
-module(hg_routing).
-include_lib("damsel/include/dmsl_domain_thrift.hrl").
-include_lib("damsel/include/dmsl_payment_processing_thrift.hrl").
-include_lib("fault_detector_proto/include/fd_proto_fault_detector_thrift.hrl").
-export([gather_routes/4]).
@ -545,7 +546,7 @@ collect_routes_for_provider(Predestination, {ProviderRef, Provider}, VS, Revisio
) -> unweighted_terminal() | no_return().
acceptable_terminal(Predestination, ProviderRef, TerminalRef, VS, Revision) ->
{Client, Context} = get_party_client(),
{ok, Terms} = party_client_thrift:compute_provider_terminal_terms(
Result = party_client_thrift:compute_provider_terminal_terms(
ProviderRef,
TerminalRef,
Revision,
@ -553,7 +554,14 @@ acceptable_terminal(Predestination, ProviderRef, TerminalRef, VS, Revision) ->
Client,
Context
),
_ = check_terms_acceptability(Predestination, Terms, VS),
ProvisionTermSet =
case Result of
{ok, Terms} ->
Terms;
{error, #payproc_ProvisionTermSetUndefined{}} ->
undefined
end,
_ = check_terms_acceptability(Predestination, ProvisionTermSet, VS),
{TerminalRef, hg_domain:get(Revision, {terminal, TerminalRef})}.
-spec get_terminal_ref(provider_terminal_ref()) -> terminal_ref().

View File

@ -1,6 +1,7 @@
-module(pm_provider).
-include_lib("damsel/include/dmsl_domain_thrift.hrl").
-include_lib("damsel/include/dmsl_payment_processing_thrift.hrl").
%% API
-export([reduce_provider/3]).
@ -27,7 +28,7 @@ reduce_provider_terminal_terms(Provider, Terminal, VS, Rev) ->
ReducedTerms = reduce_provision_term_set(MergedTerms, VS, Rev),
case ReducedTerms of
undefined ->
error({misconfiguration, {'Can\'t reduce terms', {provider, Provider}, {terminal, Terminal}}});
throw(#payproc_ProvisionTermSetUndefined{});
_ ->
ReducedTerms
end.

View File

@ -1720,19 +1720,14 @@ compute_provider_terminal_terms_undefined_terms(C) ->
Client = cfg(client, C),
DomainRevision = pm_domain:head(),
?assertMatch(
{{woody_error, {external, result_unexpected, _}}, _},
try
pm_client_party:compute_provider_terminal_terms(
?prv(2),
?trm(4),
DomainRevision,
#payproc_Varset{},
Client
)
catch
error:Error ->
Error
end
{exception, #payproc_ProvisionTermSetUndefined{}},
pm_client_party:compute_provider_terminal_terms(
?prv(2),
?trm(4),
DomainRevision,
#payproc_Varset{},
Client
)
).
compute_globals_ok(C) ->

View File

@ -11,7 +11,7 @@
{<<"cowlib">>,{pkg,<<"cowlib">>,<<"2.9.1">>},2},
{<<"damsel">>,
{git,"https://github.com/rbkmoney/damsel.git",
{ref,"66b9ae44b8c6bb788591d116c3f11985e2bb3113"}},
{ref,"908d8b4c701c38ee783e8e6012901526beb34c89"}},
0},
{<<"dmt_client">>,
{git,"https://github.com/rbkmoney/dmt_client.git",
@ -54,7 +54,7 @@
{<<"parse_trans">>,{pkg,<<"parse_trans">>,<<"3.3.1">>},2},
{<<"party_client">>,
{git,"https://github.com/rbkmoney/party_client_erlang.git",
{ref,"7bf4b7d79ce7a770ef30a91152274f7d2c68c6bc"}},
{ref,"83b8d27e26e3d4f1f16265812714e4862c40e7e3"}},
0},
{<<"payproc_errors">>,
{git,"https://github.com/rbkmoney/payproc-errors-erlang.git",