2 ms·
> You seem to be under the impression that having exceptions mean people can't handle errors explicitly? Not at all! It's possible, but it's very tedious, and
by IshKebab 3y ago
> You seem to be under the impression that having exceptions mean people can't handle errors explicitly?
Not at all! It's possible, but it's very tedious, and the lazy "catch it in main" option is so easy that in practice when you look at code that uses exceptions people actually don't handle errors explicitly.
> It means you can do so MORE granularly.
Again, it doesn't just mean that you can; it means that you will. And for proper production software that's not a good thing.
> There are unexpected errors
Only in languages with exceptions. In a language like Rust there are no unexpected errors; you have to handle errors or the compiler will shout at you.
- Capricorn2481 3y agoThat has nothing to do with having exceptions, Rust just has a good type system (something go doesn't have). But again, handling an error doesn't necessarily prevent bugs. Just because you handled an error doesn't mean the error won't happen in Prod. It just means when it does, you wrote a message for it or custom behavior. Which could be good, or it might be functionally as effective as returning a stack traces message. It depends on the situation. For what it's worth, I've never seen people not handle errors that the user could do anything with. If it's relevant to the user, we handle it.
- IshKebab 3y ago> That has nothing to do with having exceptions It absolutely does. Checked exceptions sort of half get there too but they are quite rarely used (I think they are used in Android quite well). They were actually removed from C++ because literally nobody used them. > handling an error doesn't necessarily prevent bugs. I never made that claim. > I've never seen people not handle errors that the user could do anything with. We already talked about "something went wrong" messages. Surely you have seen one of those?
- Capricorn2481 3y ago> We already talked about "something went wrong" messages. Surely you have seen one of those? My point is that "something went wrong" messages are for errors the user CANT and SHOULDNT do anything with.
- randomdata 3y ago> In a language like Rust there are no unexpected errors What? Of course there is. Rust added panic! exactly because unexpected errors are quite possible. Unexpected errors, or exceptions as they are conventionally known, are a condition that arises when the programmer made a mistake. Rust does not have a complete type system. Mistakes that only show up at runtime absolutely can be made.