I am working on a validation function. I understand that exceptions are used for errors and unexpected situations, but in the case of a validation function, if a condition is not met inside, I would expect it to return False
instead of an exception.
The thing is that after the validation finishes I need to raise an message window with a message like: "Tool exited because X condition not met"
. My workflow has been to return tuples with the result and message:
(True, Y_message)
or (False, X_condition_not_met)
and then:
a, b = result
if not a:
raise_window(message=b)
However recently I have stumbled upon multiple answers raising a controversy about this issue and I am confused. For example some people say to always go with exceptions: What's the best way to return multiple values from a function in Python? and others say tuples are the way to go Best practice in python for return value on error vs. success.
I would appreciate if someone could point me in the right direction.