I'm dealing with a JSON API that returns a number as a string. For example "12", however, this field value could also be non-numeric, for example: "-".
I've parsed the JSON data into a map and I want to extract this field to as an integer in elixir, and then perform some operation depending on where the integer falls in a certain range.
There seem to be multiple ways to do this the two main being Integer.parse/1, which returns a tuple or :error, and String.to_integer/1, which returns the integer or raises an exception.
What is the best way to perform some operation based on where the numeric value contained inside a string falls in a certain range, handling parsing errors appropriately?