Ticket #964 (closed task: fixed)

Opened 2 years ago

Last modified 15 months ago

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

Changed 2 years ago by romanb

  • type changed from defect to task

Changed 2 years ago by romanb

  • description modified (diff)

Changed 15 months ago by romanb

  • status changed from new to closed
  • severity set to abc
  • has_test unset
  • mystatus set to Pending Core Response
  • has_patch unset
  • resolution set to fixed
  • description modified (diff)
Note: See TracTickets for help on using tickets.