|
Posted by 47computers on 09/19/06 14:34
Another question just came to me...
>From within the functions in that class, can I manually throw a kind of
custom error? Say, for example, the function runs a SELECT query on a
database and all the code executes just fine, but no records are
returned. For that particular function, records really _should_ be
returned. Otherwise, something is wrong.
Would there be a way, using the trapping I have in place, to throw an
error with a custom message? Because the only other way I can think of
doing it would be to have a function within the class that sends the
error reports that my custom error handler sends and call that function
within the class.
But, not only is it generally bad design to have to re-define the same
thing in multiple places (and, subsequently, change it in multiple
places if it ever needs to be changed), but that would require some
major changes to my code since the error handler also, within itself,
creates an instance of another class that's defined in another file.
Making a long story short, I'd have to pass that object as an argument
to every function in my first class (of which there are many) and
update all function calls throughout the project. (Unless there's a
way to define an instance of the second class within the first class.
But wouldn't that require including the second class's file within the
constructor of the first class? Isn't that... messy?)
-David
[Back to original message]
|