What is the general way to handle complex results from functions with an object? A simple method can return true or false, and thatβs all I need to know. A more complex method may return true or false, but there may be more information that I would like to get out of the class, for example, why this failed (there may be several reasons).
I could do this with an exception, but I read in some places that using an exception for "normal" functions is not good practice. Also, since throwing an exception destroys the object, I cannot do anything with it, so the exception will not work if I want to continue using this object. It seems to me that an exception should be thrown when something is really wrong, and not an expected, recoverable error.
So, another way is to get the result property after the method starts, and if this method returns false, I can ask what its state is. Is this a way to do this?
source
share