4 ms·
Put another way: exceptions are exceptions to the normal program flow. They should not be used to communicate expected errors. I think of them as analogous to t
by toxik 7y ago
Put another way: exceptions are exceptions to the normal program flow. They should not be used to communicate expected errors. I think of them as analogous to the `if (do() != 0) { goto out; }` paradigm of C.
- ChrisSD 7y agoUnless you're using Python where exceptions occur every time you finish looping. https://docs.python.org/3.7/library/exceptions.html#StopIteration https://docs.python.org/3.7/library/exceptions.html#StopIter...
- benji-york 7y agoTrue. However, it is unusual for the user to deal with StopIteration themselves (therefore somewhat exceptional).
- reallydude 7y agoIn my experience, this isn't always true. Exceptions are great in the context of web requests. If anything goes wrong, we have defined consistent behavior (re: http 404). It's so effective, there's a whole host of checked exception codes.
- asdfasgasdgasdg 7y ago> Put another way: exceptions are exceptions to the normal program flow. There's no iron law or mathematical proof that says this is optimal. It's just a preference some people have. Exceptions are the error handling mechanism for many programming languages. Authorization errors are a type of error. Under this construction, exceptions are the appropriate way to handle authorization errors, including when a principal attempts to access an resource they are not authorized to access.