I was using function Float.of_string to convert an input obtained by a formular.
Surely the user could be a bad guys and write a sentence instead of a float number in the input :)
There is lot of solution, to test the string input... But In my mind the function float.of_string, should test, it's obligatory to transform into a float. And as an evidence when the string is not a float... The server will reach an error which kill the server (or at minimum the session).
Then I think, the best will be (choice) :
- Return an option
- A way to catch error before it kill the session...
Then the true question of this post, is : Is there a way to do something like try/catch block for the OPA uncaught exception. And if yes how it works, and is it possible to throw an error in our own function ?
Thanks for your answer, Matthieu