MSPF-224: fix error format in case of TApplicationException exception from server in 200 (#55)

This commit is contained in:
Anton Belyaev 2017-04-28 18:26:42 +04:00 committed by Petr Kozorezov
parent 8f1f42e209
commit 992c279466
2 changed files with 8 additions and 5 deletions

View File

@ -4,7 +4,6 @@
#{
dirs => ["src", "test"],
filter => "*.erl",
ignore => ["_thrift.erl$"],
rules => [
{elvis_style, line_length, #{limit => 120, skip_comments => false}},
{elvis_style, no_tabs},
@ -14,7 +13,7 @@
{elvis_style, nesting_level, #{level => 3}},
{elvis_style, god_modules, #{limit => 25, ignore => [woody_tests_SUITE]}},
{elvis_style, no_if_expression},
{elvis_style, invalid_dynamic_call, #{}},
{elvis_style, invalid_dynamic_call, #{ignore => [woody_client_thrift]}},
{elvis_style, used_ignored_variable},
{elvis_style, no_behavior_info},
{elvis_style, module_naming_convention, #{regex => "^[a-z]([a-z0-9]*_?)*(_SUITE)?$"}},

View File

@ -73,10 +73,8 @@ get_transport_opts(Opts) ->
do_call(Client, Function, Args, Context) ->
{ClientNext, Result} = try thrift_client:call(Client, Function, Args)
catch
%% In case a server violates the requirements and sends
%% #TAppiacationException{} with http status code 200.
throw:{Client1, {exception, #'TApplicationException'{}}} ->
{Client1, {error, {external, result_unexpected, <<"thrift application exception unknown">>}}};
{Client1, {error, {system, get_server_violation_error()}}};
throw:{Client1, {exception, ThriftExcept}} ->
{Client1, {error, {business, ThriftExcept}}}
end,
@ -84,6 +82,12 @@ do_call(Client, Function, Args, Context) ->
log_result(Result, Context),
map_result(Result).
get_server_violation_error() ->
{external, result_unexpected, <<
"server violated thrift protocol: "
"sent TApplicationException (unknown exception) with http code 200"
>>}.
log_result({error, {business, ThriftExcept}}, Context) ->
log_event(?EV_SERVICE_RESULT, Context, #{status => ok, result => ThriftExcept});
log_result({Status, Result}, Context) ->