Skip to content

Commit

Permalink
Fix linter "nested try-catch"
Browse files Browse the repository at this point in the history
  • Loading branch information
seriyps committed Nov 21, 2023
1 parent 8b0bece commit 2a5aee0
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/logger_journald_h.erl
Original file line number Diff line number Diff line change
Expand Up @@ -335,16 +335,21 @@ ensure_bytes(V) when is_list(V) ->
_ -> V
catch
error:badarg ->
try unicode:characters_to_binary(V)
catch error:badarg ->
io_lib:format("~w", [V])
end
non_io_list_to_bytes(V)
end;
ensure_bytes(V) when is_integer(V) ->
integer_to_binary(V);
ensure_bytes(V) when is_atom(V) ->
atom_to_binary(V, utf8).

non_io_list_to_bytes(V) ->
try
unicode:characters_to_binary(V)
catch
error:badarg ->
iolist_to_binary(io_lib:format("~w", [V]))
end.

%% Overlaod protection

overload_init(#{id := Name} = _Conf) ->
Expand Down

0 comments on commit 2a5aee0

Please sign in to comment.