narrowtux / abacus

Parses and evaluates mathematical expressions in Elixir. Inspired by math.js
MIT License
84 stars 18 forks source link

Return error tuple when Abacus.eval() runs into an unexcepted error #12

Closed texjim closed 7 years ago

texjim commented 7 years ago

Added {:error, _} return on Abacus.eval() when there is the expression is invalid or contains an unexpected token Added unit test to test that Abacus.eval("1 + )") returns an error tuple.

narrowtux commented 7 years ago

Oh, turns out I used with in the wrong way. It should also work with {:ok, parsed} <- parse(expr), but this fix is fine too, thanks for the submission :)