feat(upload certs): serialize errors about saving cert
This commit is contained in:
parent
ee178ccea9
commit
1a61640b15
|
@ -202,7 +202,7 @@ do_pre_config_update({create_authenticator, _ChainName, Config}, OldConfig) ->
|
||||||
NConfig ->
|
NConfig ->
|
||||||
{ok, OldConfig ++ [NConfig]}
|
{ok, OldConfig ++ [NConfig]}
|
||||||
catch
|
catch
|
||||||
error:{convert_cert_option, _} = Reason ->
|
error:{save_cert_to_file, _} = Reason ->
|
||||||
{error, Reason}
|
{error, Reason}
|
||||||
end;
|
end;
|
||||||
do_pre_config_update({delete_authenticator, _ChainName, AuthenticatorID}, OldConfig) ->
|
do_pre_config_update({delete_authenticator, _ChainName, AuthenticatorID}, OldConfig) ->
|
||||||
|
@ -220,7 +220,7 @@ do_pre_config_update({update_authenticator, _ChainName, AuthenticatorID, Config}
|
||||||
NewConfig ->
|
NewConfig ->
|
||||||
{ok, NewConfig}
|
{ok, NewConfig}
|
||||||
catch
|
catch
|
||||||
error:{convert_cert_option, _} = Reason ->
|
error:{save_cert_to_file, _} = Reason ->
|
||||||
{error, Reason}
|
{error, Reason}
|
||||||
end;
|
end;
|
||||||
do_pre_config_update({move_authenticator, _ChainName, AuthenticatorID, Position}, OldConfig) ->
|
do_pre_config_update({move_authenticator, _ChainName, AuthenticatorID, Position}, OldConfig) ->
|
||||||
|
|
|
@ -2024,6 +2024,16 @@ serialize_error(unsupported_operation) ->
|
||||||
{400, #{code => <<"BAD_REQUEST">>,
|
{400, #{code => <<"BAD_REQUEST">>,
|
||||||
message => <<"Operation not supported in this authentication type">>}};
|
message => <<"Operation not supported in this authentication type">>}};
|
||||||
|
|
||||||
|
serialize_error({save_cert_to_file, invalid_certificate}) ->
|
||||||
|
{400, #{code => <<"BAD_REQUEST">>,
|
||||||
|
message => <<"Invalid certificate">>}};
|
||||||
|
|
||||||
|
serialize_error({save_cert_to_file, {_, Reason}}) ->
|
||||||
|
{500, #{code => <<"INTERNAL_SERVER_ERROR">>,
|
||||||
|
message => list_to_binary(
|
||||||
|
io_lib:format("Cannot save certificate to file due to '~p'", [Reason])
|
||||||
|
)}};
|
||||||
|
|
||||||
serialize_error({missing_parameter, Name}) ->
|
serialize_error({missing_parameter, Name}) ->
|
||||||
{400, #{code => <<"MISSING_PARAMETER">>,
|
{400, #{code => <<"MISSING_PARAMETER">>,
|
||||||
message => list_to_binary(
|
message => list_to_binary(
|
||||||
|
|
Loading…
Reference in New Issue