From 91cf144d3c3c6974479cced2383d1b7c6c7bac94 Mon Sep 17 00:00:00 2001 From: Jan Schneider Date: Mon, 13 Dec 2010 18:43:51 +0100 Subject: [PATCH] Allow to provide additional details with exceptions. For now include PEAR_Error's userinfo. --- framework/Exception/lib/Horde/Exception.php | 16 +++++++++++++++- framework/Exception/lib/Horde/Exception/Pear.php | 3 +++ framework/Exception/lib/Horde/Exception/Prior.php | 4 ++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/framework/Exception/lib/Horde/Exception.php b/framework/Exception/lib/Horde/Exception.php index 84f5cfe67..790acb5f3 100644 --- a/framework/Exception/lib/Horde/Exception.php +++ b/framework/Exception/lib/Horde/Exception.php @@ -16,10 +16,17 @@ if (version_compare(PHP_VERSION, '5.3.0', '<')) { */ class Horde_Exception extends Exception { - private $_previous = null; /** + * Error details that should not be part of the main exception message, + * e.g. any additional debugging information. + * + * @var string + */ + public $details; + + /** * Construct the exception * * @param string $msg @@ -71,5 +78,12 @@ if (version_compare(PHP_VERSION, '5.3.0', '<')) { */ class Horde_Exception extends Exception { + /** + * Error details that should not be part of the main exception message, + * e.g. any additional debugging information. + * + * @var string + */ + public $details; } } diff --git a/framework/Exception/lib/Horde/Exception/Pear.php b/framework/Exception/lib/Horde/Exception/Pear.php index 0f9d76c5e..d26feeb48 100644 --- a/framework/Exception/lib/Horde/Exception/Pear.php +++ b/framework/Exception/lib/Horde/Exception/Pear.php @@ -37,6 +37,9 @@ class Horde_Exception_Pear extends Horde_Exception $error->getMessage() . $this->_getPearTrace($error), $error->getCode() ); + if ($details = $error->getUserInfo()) { + $this->details = $details; + } } /** diff --git a/framework/Exception/lib/Horde/Exception/Prior.php b/framework/Exception/lib/Horde/Exception/Prior.php index a71d948c6..e9dfc1bae 100644 --- a/framework/Exception/lib/Horde/Exception/Prior.php +++ b/framework/Exception/lib/Horde/Exception/Prior.php @@ -32,6 +32,10 @@ class Horde_Exception_Prior extends Horde_Exception if ($message instanceof Exception) { $previous = $message; } + if (method_exists($message, 'getUserinfo') && + $details = $message->getUserinfo()) { + $this->details = $details; + } $message = $message->getMessage(); } -- 2.11.0