#Piping into `result.try`
1 messages · Page 1 of 1 (latest)
I would generally write it like this:
import result.{try}
// ...
use happy_path_value <- try(
do_stuff()
|> result.replace_error(MyErrorVariant)
)
1 messages · Page 1 of 1 (latest)
Is there a better way to write this?
use happy_path_value <-
do_stuff()
|> result.replace_error(MyErrorVariant)
|> fn(x) { result.try(x, _) }
I don't like writing the fn in there.
I would generally write it like this:
import result.{try}
// ...
use happy_path_value <- try(
do_stuff()
|> result.replace_error(MyErrorVariant)
)