Ticket #964 (closed task: fixed)
Introduce new exception syntax
| Reported by: | romanb | Owned by: | romanb |
|---|---|---|---|
| Priority: | minor | Milestone: | 2.0.0 (OLD) |
| Component: | Other | Version: | 2.0-DEV |
| Severity: | abc | Keywords: | exceptions |
| Cc: | Has Test: | no | |
| Status: | Pending Core Response | Has Patch: | no |
Description (last modified by romanb) (diff)
Introduce new exception syntax throughout the code. Example:
// definition
class Doctrine_Xyz_Exception extends Doctrine_Exception
{
// without param
public static function foobarIsInvalid()
{
return new self("Foobar is in an invalid operation. Please do something entirely different. Just do it.");
}
// with param
public static function failedToFindKey($key)
{
return new self("I've tried and tried and tried but i can't find the key ($key) you gave me. I'm sorry. I give up.");
}
}
// throwing code
...
throw Doctrine_Xyz_Exception::foobarIsInvalid();
or
throw Doctrine_Xyz_Exception::failedToFindKey($theKey);
...
Advantages: * Exception messages are all defined together in the Exception classes they belong to. * Exception messages can be more precise and verbose without cluttering the code that throws the exception. The code that throws the exception gets a more compact and concise look.
With namespaces the throwing code will get even more concise: throw XyzException::foobarIsInvalid();
Change History
Note: See
TracTickets for help on using
tickets.