Re: DB_QueryTool, MDB_QueryTool, and error handling
| From: | till | Date: | Sat, 25 Oct 2008 13:16:56 +0000 |
| Subject: | Re: DB_QueryTool, MDB_QueryTool, and error handling | ||
| References: | 1 2 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-50912@lists.php.net to get a copy of this message | ||
On Sat, Oct 25, 2008 at 10:21 AM, Christian Weiske <cweiske@cweiske.de> wrote:
> Hello Daniel,
>
>
>> Does anyone have suggestions on good approaches to fix:
>> http://pear.php.net/bugs/bug.php?id=14862
>>
>> In a nutshell, connection to the database happens in the constructor
>> in both of these packages, and if it's wrong, an error object is
>> returned.
>>
>> My first instincts are to raise an exception (but can't because it's
>> a PHP4 package), or explicitly pass in the database connection object
>> (that would be a BC break, but improves testability)
>
> MDB2 itself "fixes" the problem by returning a PEAR_Error object in the
> factory method. Since you're using a constructor, this isn't possible :/
> But you could add a factory method.
> Putting all those error checks in all methods might be an overkill.
>
We added hasErrors() and getErrors() to Mail_Queue because of a similar problem.
Till