3 ms·
That is another viable strategy if you don't want to handle the login failure in any graceful way.
by strictfp 15y ago
That is another viable strategy if you don't want to handle the login failure in any graceful way.
- politician 15y agoExceptions are not a crash-or-nothing proposition. The idea is that the caller should handle them at the earliest point in the call-stack that can do something reasonable about the problem. Also, let me clarify that I don't believe that exceptions should be used as the only way to return values from a method in languages that support them. They are simply a tool with certain properties (among them, the ability to be more difficult to ignore, the topic at hand).
- strictfp 15y agoI generally find that one should avoid using exceptions for flow control. They have their usages, but they should in my opinion only be used when they really shine - when you have multiple levels of callers between the detection of the error and the handling. This was not the case in the simple example, and so I chose a return value instead of an exception.