Hi, all. I'm looking for a "straw poll" of opinions on two ways to
implement part of an exception hierarchy. Forgive the silly example I
offer, but its what came to mind on the fly as I decided how to
illustrate the question.
Let's assume you have an application called "FruitStore," with a
component called "FruitInventory," and it has a method
AddFruit("fruitname"). The relevant rule for this discussion is that
each "fruitname" in the inventory must be unique.
The broader application FruitStore, which maintains a variety of other
information, has a generic exception called DuplicateDataException.
Upon detection of a duplicate fruit in the AddFruit method, the method
has two options:
1. It can throw the generic DuplicateDataException.
2. It can define and throw its own exception, called
DuplicateFruitException.
Consideration: The DuplicateDataException allows for a string message
as a parameter in its constructor that might say "Duplicate fruit
"fruitname" detected."
Which, if either, would the learned ones here advocate?
Please reply to group...email is long dead.
Thanks,
David