3 ms·
I disagree. I have seen plenty of code that is forced to match on the text of an exception because it uses a too-generic type. That said, I still wouldn't use
by IshKebab 4y ago
I disagree. I have seen plenty of code that is forced to match on the text of an exception because it uses a too-generic type.
That said, I still wouldn't use a custom exception type in most languages simply because it's so tedious for a small pay-off. It's one of those things that you should do, but isn't really worth the hassle. Like putting alt text on HTML images.
Do any languages with exceptions let you define new exception types at the throw site?
- Psyonic 4y agoI don't see how an exception type defined at the throw site would be significantly different than using the text of the exception to convey the type. Callers wouldn't know to expect it either way, so how would they be able to handle it effectively?