mirror of
https://github.com/dg/dibi.git
synced 2025-10-25 03:36:23 +02:00
DibiException is NException descendant
This commit is contained in:
@@ -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
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user