2 ms·
Assume all methods can throw exceptions. And if, by chance, you believe a method doesn't throw an exception today you have no idea if it's implementation will
by wvenable 6y ago
Assume all methods can throw exceptions. And if, by chance, you believe a method doesn't throw an exception today you have no idea if it's implementation will change tomorrow and it will then throw an exception.
Whether a method throws an exception or not doesn't matter as much as people think it does. You can rarely recover from an exception in the immediate parent calling method anyway. More than likely the error will occur in a stack 20 layers deep and recovery is to restart the entire operation from the start.
Nulls are useful but I totally agree that they should be opt-in in the type system.