Thoas - Elixir's Jason JSON library converted to Erlang

Erlang may be getting a solution to this via EEP 49, that would become:

do_steps(Arg) ->
    maybe
        {ok, Success} ?= step1(Arg),
        {ok, Success2} ?= step2(Success),
        {ok, Success3} ?= step3(Success2),
        {ok, Success3}
    end.

That has a different return value, and the errors aren’t exceptional, json errors are very common and part of code flow, shouldn’t be hidden.

And that way will indeed throw if it is not a success, which gives you your throwing transparently while handling errors if you wish as well. :slight_smile:

Yep this thing!

+1

It’s trivial enough to make a wrapper module that follows other library API’s but exposes your as well.

+1

4 Likes