lpil / snag

⛵ A boilerplate-free ad-hoc error type
Apache License 2.0
49 stars 2 forks source link

utility function for converting from arbitrary errors #2

Open aslilac opened 9 months ago

aslilac commented 9 months ago

it'd be nice to have something like...

pub fn convert(tried: Result(a,b)) -> Snag(a) {
  tried
  |> result.map_error(fn(e) {
    e
    |> string.inspect()
    |> error()
  })
}

for quickly turning any error into a Snag

aslilac commented 9 months ago

alternatively could be named from or something

lpil commented 9 months ago

This would result in very poor error messages so I'm not sure this is a good idea. It won't have any information written for humans, and it could contain data of any size and shape.