snag icon indicating copy to clipboard operation
snag copied to clipboard

Consider a replace error function

Open jrstrunk opened this issue 2 months ago • 2 comments

Hello! Long-time enjoyer of the package here. I often end up writing this in my pipelines:

dict.get(..)
|> result.replace_error(snag.new("reason"))

This works, but over time it has gotten tedious. I would much prefer a more straightforward call, like:

dict.get(..)
|> snag.replace_error("reason")

I end up writing this a lot, as all my functions return Snags, but many library functions return Result(.., Nil)

What do you think of adding a function like this?

jrstrunk avatar Oct 01 '25 01:10 jrstrunk

Sounds great to me!! Want to make a PR?

lpil avatar Oct 01 '25 16:10 lpil

Fantastic! I'll open a PR tomorrow for it!

jrstrunk avatar Oct 02 '25 01:10 jrstrunk