refactor: improve error messages

This commit is contained in:
Thales Macedo Garitezi 2024-07-01 10:27:25 -03:00
parent 795d280861
commit b14856cf1a
3 changed files with 7 additions and 3 deletions

View File

@ -55,7 +55,10 @@ map_bad_ssl_error(#{pem_check := invalid_pem} = TLSLibError) ->
kind => validation_error,
reason => <<"bad_ssl_config">>,
bad_fields => Paths,
file_read_error => Reason
details => emqx_utils:format(
"Failed to access certificate / key file: ~s",
[emqx_utils:explain_posix(Reason)]
)
};
map_bad_ssl_error(#{which_options := Paths, reason := Reason}) ->
#{

View File

@ -738,7 +738,8 @@ t_create_with_bad_tls_files(Config) ->
#{
<<"kind">> := <<"validation_error">>,
<<"reason">> := <<"bad_ssl_config">>,
<<"file_read_error">> := <<"enoent">>,
<<"details">> :=
<<"Failed to access certificate / key file: No such file or directory">>,
<<"bad_fields">> := [[<<"cacertfile">>]]
},
json(Msg0)

View File

@ -238,7 +238,7 @@ t_persist_ssl_certfiles(Config) ->
list_ssl_certfiles(Config)
),
?assertMatch(
{error, {pre_config_update, _, {bad_ssl_config, #{}}}},
{error, {pre_config_update, _, #{reason := <<"bad_ssl_config">>}}},
emqx_ft_conf:update(
mk_storage(true, #{
<<"s3">> => mk_s3_config(#{