chore(authn): add the serialization of more errors
This commit is contained in:
parent
ce851e5b0f
commit
b5ded1ece0
|
@ -1962,9 +1962,11 @@ serialize_error({not_found, {authenticator, ID}}) ->
|
||||||
serialize_error({not_found, {listener, ID}}) ->
|
serialize_error({not_found, {listener, ID}}) ->
|
||||||
{404, #{code => <<"NOT_FOUND">>,
|
{404, #{code => <<"NOT_FOUND">>,
|
||||||
message => list_to_binary(io_lib:format("Listener '~s' does not exist", [ID]))}};
|
message => list_to_binary(io_lib:format("Listener '~s' does not exist", [ID]))}};
|
||||||
serialize_error(name_has_be_used) ->
|
serialize_error({already_exists, {authenticator, ID}}) ->
|
||||||
{409, #{code => <<"ALREADY_EXISTS">>,
|
{409, #{code => <<"ALREADY_EXISTS">>,
|
||||||
message => <<"Name has be used">>}};
|
message => list_to_binary(
|
||||||
|
io_lib:format("Authenticator '~s' already exist", [ID])
|
||||||
|
)}};
|
||||||
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(
|
||||||
|
@ -1977,7 +1979,7 @@ serialize_error({invalid_parameter, Name}) ->
|
||||||
)}};
|
)}};
|
||||||
serialize_error(Reason) ->
|
serialize_error(Reason) ->
|
||||||
{400, #{code => <<"BAD_REQUEST">>,
|
{400, #{code => <<"BAD_REQUEST">>,
|
||||||
message => list_to_binary(io_lib:format("Todo: ~p", [Reason]))}}.
|
message => list_to_binary(io_lib:format("~p", [Reason]))}}.
|
||||||
|
|
||||||
to_list(M) when is_map(M) ->
|
to_list(M) when is_map(M) ->
|
||||||
[M];
|
[M];
|
||||||
|
|
Loading…
Reference in New Issue