Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return index of undecodable element in dynamic.list DecodeError path #627

Open
johtso opened this issue Jun 9, 2024 · 1 comment · May be fixed by #628
Open

Return index of undecodable element in dynamic.list DecodeError path #627

johtso opened this issue Jun 9, 2024 · 1 comment · May be fixed by #628

Comments

@johtso
Copy link
Contributor

johtso commented Jun 9, 2024

pub fn list(
of decoder_type: fn(Dynamic) -> Result(inner, DecodeErrors),
) -> Decoder(List(inner)) {
fn(dynamic) {
use list <- result.try(shallow_list(dynamic))
list
|> list.try_map(decoder_type)
|> map_errors(push_path(_, "*"))
}
}

I think it would be nice to return the index of the offending element instead of just "*"

I'm new to gleam, but I had a little play around trying to implement this and could open a pull request..

@lpil
Copy link
Member

lpil commented Jun 12, 2024

Fab idea! Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants