The Elixir "getting started" section on exceptions seemed to suggest that
code shouldn't throw exceptions tin the course of normal data processing. I
would normally have raised exceptions where they were encountered, but I
wanted to adhere to the language style where possible.

After I worked with it a bit, I actually liked seeing the {
:unexpected_token, s } being passed up the chain. I particularly liked how
invisible it is in the Numerical code. I'd like to do some more cleanup on
the Object and Array parsing eventually.

On Sunday, July 21, 2013, Carlos Brito Lage wrote:

> In lib/json/decode.ex:
>
> >    end
> >
> > -  def from_json(bitstring) when is_bitstring(bitstring) do
> > -    accept_root(bitstring)
> > +  def from_json!(s) when is_binary(s) do
>
> Do you think it makes the code easier to maintain/understand making
> "function_call!" always encapsulate "function_call" and not vice-versa? I'm
> genuinely curious. This doubt could very well originate from my non-Erlang
> background. Is this a FP / Erlang convention I'm not aware of?
>
> I assumed raising an exception where the issue happens and waiting until
> the "end" for the conversion from a caught exception to {:error, "error
> message"} would improve the code readability by allowing to interrupt the
> execution of the flow immediately, and not having to do pattern matching
> like this:
> https://github.com/jamesarosen/elixir-json/blob/d3e7781dcb6154cf69d646239a0bdab207e576d1/lib/json/decode.ex#L15
>
> Thanks! [image: :metal:]
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/cblage/elixir-json/pull/3/files#r5312161>
> .
>