Reputation: 5819
Just as an example, let’s take a method for getting the App Support directory. What if NSSearchPathForDirectoriesInDomains
returns no elements? What if it’s not a directory but a file? What if it couldn’t be created?
My methods are getting cluttered up not just by adding doing the checks but also from constructing the error objects, assigning error codes etc.
Upvotes: 1
Views: 81
Reputation: 458
You probably are overdoing it. From your example, if that function is returning no elements or a file, then something is seriously wrong, and there's no way that your application can recover from it. At that point, letting the error cause a crash is the only sensible thing to do.
Upvotes: 1