1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-12 00:54:11 +02:00

DibiException is NException descendant

This commit is contained in:
David Grudl
2007-11-18 02:29:11 +00:00
parent cbb315cbc7
commit 58ed8d34f4
4 changed files with 58 additions and 20 deletions

View File

@@ -27,7 +27,7 @@
* @package dibi
* @version $Revision$ $Date$
*/
class DibiException extends Exception
class DibiException extends NException
{
}

View File

@@ -30,6 +30,9 @@
*/
class NException extends Exception
{
/** @var Exception */
private $cause;
/** @var callback */
private static $oldHandler;
@@ -37,6 +40,49 @@ class NException extends Exception
private static $handlerClass;
/**
* Initializes the cause of this throwable to the specified value
*
* @param Exception
* @return void
*/
public function initCause(Exception $cause)
{
if ($this->cause === NULL) {
$this->cause = $cause;
} else {
throw new BadMethodCallException('Cause was already assigned');
}
}
/**
* Gets the Exception instance that caused the current exception
*
* @return Exception
*/
public function getCause()
{
return $this->cause;
}
/**
* Returns string represenation of exception
*
* @return void
*/
public function __toString()
{
return parent::__toString() . ($this->cause === NULL ? '' : "\nCaused by " . $this->cause->__toString());
}
/**
* Enables converting all PHP errors to exceptions
*

View File

@@ -198,7 +198,7 @@ abstract class NObject
/**
* Does method exist? Case sensitive, filters protected & private, doesn't recognize static methods (works good since 5.0.4)
* Does public method exist? (case sensitive)
*
* @param string class name
* @param string method name
@@ -208,6 +208,11 @@ abstract class NObject
{
static $cache;
if (!isset($cache[$c])) {
// get_class_methods returns private, protected and public methods of NObject (doesn't matter)
// only only public methods of descendants (perfect!)
// but returns static methods too (nothing doing...)
// and is much faster than reflection
// (works good since 5.0.4)
$cache[$c] = array_flip(get_class_methods($c));
}
return isset($cache[$c][$m]);