I used the Float.of_string function to convert the input received by the formal.
Of course, the user can be a bad guy and write a sentence instead of a floating point number in the input :)
There are many solutions to check the input of a string ... But, in my opinion, the function float.of_string, should check, is required to convert to a float. And as proof that the string is not a float ... The server will achieve an error that kills the server (or at least the session).
Then I think the best would be (choice):
- Return option
- A way to catch a mistake before he kills a session ...
Then the true question of this post is: Is there a way to do something like a try / catch block for an OPA thrown exception. And if so, how does it work, and is it possible to issue an error in our own function?
Thank you for your reply, Mathieu.
source share