I've seen a few styles on exceptions and particularly when to raise them in a class.
A concrete example should clarify:
A calls B's constructor (ctor) with argument file path.
The file path could be false.
Should B check the file path in the ctor and throw or merely save the value to attribute and throw when it's used if need be?
There are no concrete absolute truths on something like this but I'd like different points of view on this.
Not throwing in the ctor makes it easier to use since exception isn't possible and when applying
this idea more broadly, there could be various other methods that could be handled without a risk of
exception if the ctor checks the path before hand.
Thoughts?


Sign In
Create Account


Back to top









