Exceptions related to a particular class are always named for that
class. Generic exceptions use an _Exception
name
suffix, and specific exceptions add a single string after that.
For example, a generic example exception would be
Acme_Example_Exception
, while related FooBar and
BazDib exceptions would be named
Acme_Example_Exception_FooBar
and
Acme_Example_Exception_BazDib
, respectively.
Acme/ Example.php Example/ Exception.php Exception/ FooBar.php BazDib.php
Classes descended from Solar_Base automatically convert specific error codes into exception class names, and then attempt to use a related locale string for the exception message.
For example, if you have this in your locale file ...
<?php
return array (
'ERR_FOO_BAR' => "A foo-bar exception occurred.",
'ERR_BAZ_DIB' => "Baz-dib was raised, you should look into it.",
);
... and you throw an exception using Solar_Base::_exception() like so ...
<?php
class Acme_Example extends Solar_Base {
function kaboom()
{
throw $this->_exception('ERR_FOO_BAR');
}
}
... then Solar automatically finds the
Acme_Example_Exception_FooBar
class and throws it,
using the localized ERR_FOO_BAR
message.