New Releases!
It's been a busy weekend playing catchup on bug reports and feature requests. These projects of mine have seen new releases yesterday and today as a result:
* Contact_Vcard_Build 1.1.1 (bugfixes)
* Contact_Vcard_Parse 1.31.0 (bugfixes)
* DB_Table 1.0.1 (bugfixes)
* Savant3 dev 4
The new Savant release bears a little talking-about. I don't like breaking backwards compatibility even in a development release if I can help it, but there was one issue that required an architectural change related to error handling. That is the removal of error-handling resources (e.g., Savant3_Error_pear, et. al.), which is pretty significant if you use it. (Exceptions are a special case; see below for more on that.)
The original purpose of having error-handling resources was so that you could report and test for errors using your own framework-specific calls. While the Savant3 error resources would allow you to plug into those systems, the number-one complaint I got was that Savant3 still returned errors as Savant3_Error objects, which meant that you had to use Savant3 to check for errors, not the framework-specific error checker. That's obviously a problem, as it doesn't meet the original goal of being able to abstract error reporting and testing.
As a result, I have removed the error-handling resource infrastructure. Instead, if you want to use framework-specific error reporting and testing, you should extend Savant3 and override the error() and isError() methods. For example, if you wanted to use PEAR_Error handling, you would do something like this:
include_once 'Savant3.php';
class Savant3_Pear extends Savant3 {
public method error($code, $info = array(), $level = E_USER_ERROR,
$trace = true)
{
if (! class_exists('PEAR_Error')) {
include_once 'PEAR.php';
}
$err = PEAR::raiseError($code, $code, $info, $level);
return $err;
}
public function isError($obj)
{
if (! class_exists('PEAR_Error')) {
include_once 'PEAR.php';
}
return PEAR::isError($obj);
}
}
The difference between this and the previous (Savant2) error handler resource architecture is that the call to error() will return a PEAR_Error, not a Savant3_Error. In addition, while you can test for errors using the extended isError() method, you can use PEAR::isError() instead because the returned error object is a real PEAR_Error object. This applies to all frameworks that use their own error handling systems (which is, well, almost all frameworks, including Solar, which now bundles Savant3 as its default template system).
Exceptions are a special case; they're native to PHP5, so they have native support in Savant3 now (instead of being an error handler resource). If you want Savant3 to throw exceptions, call setExceptions(true) and it'll throw Savant3_Exception objects when errors occur.
For full change notes, be sure to visit the Savant3 website.