Hello. I am starting coding in Elixir right now and I have some questions.
I am creating a simple script and want to handle with incorrect type of inputs.
Let’s imagine I have this simple function:
def currencyConverter({ from, to, amount }) do
result = exchangeConversion({ from, to, amount })
exchangeResult = resultParser(result)
exchangeResult
end
And I need to guarantee that “from” and “to” are strings and “amount” is boolean and want to handle this error sending customized messages instead explode an erlang error in the terminal
Which is the best way? use an if is_float(amount) … else, or I have a more elegant ways?