Replace Exception with test
From CSSEMediaWiki
Revision as of 23:00, 14 October 2009 by Brett Ward (Talk | contribs)
While using Replace Error Code with Exception is an improvement, exceptions should still only be used for exceptional behaviour. They should not act as a substitute for tests.
The caller of the method throwing the exception should pass the test first. A simple example would be returning a value from an array - rather than throwing an ArrayOutOfBoundsException, you would check that the value passed is within array boundaries before checking the array.
See Also: