Background
I want to convert a String to an integer. To this extent I know I can use one of the two following functions:
String.to_integerInteger.parse
My concern
My concern here is the API. With option 1 if the string is invalid, it will just raise an exception and explode. This is not very elixiry as it forces me down to a try/rescue approach.
So the alternative would be option 2. Except the API for this function is rather inconsistent. Sometimes it will return :error other times it will just explode. Quite literally, I do not know what to expect, so I still need to use a try/rescue here as well.
Question
My objective is to have a parsing function that returns a tagged tuple for the errors. Something among the lines of {:error, reason}. Now, I know I can easily create one, but I was wondering if there is a function in Elixir that already does this.
Is there any parse function in Elixir that already returns tagged tupples when parsing data?






















