Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
The input tuple is emitted by `Toml.decode/2`.
@spec filter({atom, any}, String.t) :: map
# @spec filter( {:ok | :error, any}, String.t) :: map
defp filter({status, payload}, trim_path) do
# Filter the parsing results, reporting and removing cruft.
# If a problem is detected, report it and return an empty Map.
# Otherwise, return the parsed data.
cond do
status == :error ->
IO.puts "\nIgnored: " <> trim_path
IO.puts "Because: " <> inspect(payload)
not(is_map(payload)) ->
IO.puts "\nIgnored: " <> trim_path
IO.puts "Because: Payload is not a Map."
Enum.empty?(payload) ->
IO.puts "\nIgnored: " <> trim_path
IO.puts "Because: Payload is empty."
true -> payload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment