From b311f5e4bb91736544cd5fd0502a200bec4cd62b Mon Sep 17 00:00:00 2001
From: Olav Morken <olav.morken@uninett.no>
Date: Fri, 6 Aug 2010 07:22:07 +0000
Subject: [PATCH] SimpleSAML_Error_UnserializableException: Preserve classname
 for logging.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2483 44740490-163a-0410-bde0-09ae8108e29a
---
 lib/SimpleSAML/Error/Exception.php            | 12 +++++++-
 .../Error/UnserializableException.php         | 28 +++++++++++++++++--
 2 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/lib/SimpleSAML/Error/Exception.php b/lib/SimpleSAML/Error/Exception.php
index 8820448e8..fb8b62a1c 100644
--- a/lib/SimpleSAML/Error/Exception.php
+++ b/lib/SimpleSAML/Error/Exception.php
@@ -92,6 +92,16 @@ class SimpleSAML_Error_Exception extends Exception {
 	}
 
 
+	/**
+	 * Retrieve the class of this exception.
+	 *
+	 * @return string  The classname.
+	 */
+	public function getClass() {
+		return get_class($this);
+	}
+
+
 	/**
 	 * Format this exception for logging.
 	 *
@@ -105,7 +115,7 @@ class SimpleSAML_Error_Exception extends Exception {
 
 		$e = $this;
 		do {
-			$err = get_class($e) . ': ' . $e->getMessage();
+			$err = $e->getClass() . ': ' . $e->getMessage();
 			if ($e === $this) {
 				$ret[] = $err;
 			} else {
diff --git a/lib/SimpleSAML/Error/UnserializableException.php b/lib/SimpleSAML/Error/UnserializableException.php
index 9a5995c04..004744049 100644
--- a/lib/SimpleSAML/Error/UnserializableException.php
+++ b/lib/SimpleSAML/Error/UnserializableException.php
@@ -15,9 +15,23 @@
  */
 class SimpleSAML_Error_UnserializableException extends SimpleSAML_Error_Exception {
 
+	/**
+	 * The classname of the original exception.
+	 *
+	 * @var string
+	 */
+	private $class;
+
+
+	/**
+	 * Create a serializable exception representing an unserializable exception.
+	 *
+	 * @param Exception $original  The original exception.
+	 */
 	public function __construct(Exception $original) {
 
-		$msg = get_class($original) . ': ' . $original->getMessage();
+		$this->class = get_class($original);
+		$msg = $original->getMessage();
 		$code = $original->getCode();
 
 		if (!is_int($code)) {
@@ -30,4 +44,14 @@ class SimpleSAML_Error_UnserializableException extends SimpleSAML_Error_Exceptio
 		$this->setBacktrace(SimpleSAML_Utilities::buildBacktrace($original));
 	}
 
-}
\ No newline at end of file
+
+	/**
+	 * Retrieve the class of this exception.
+	 *
+	 * @return string  The classname.
+	 */
+	public function getClass() {
+		return $this->class;
+	}
+
+}
-- 
GitLab