From 4730ba86704ba0127d7805d42bb860b1f411f5fb Mon Sep 17 00:00:00 2001 From: Olav Morken <olav.morken@uninett.no> Date: Mon, 13 Jul 2009 06:16:01 +0000 Subject: [PATCH] Add exception for serializing unserializable exceptions. The SimpleSAML_Error_Exception class is a base class for serializable exceptions. This patch adds SimpleSAML_Error_UnserializableException. That class saves some of the information from an Exception and saves it in an serializable exception. git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1564 44740490-163a-0410-bde0-09ae8108e29a --- .../Error/UnserializableException.php | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 lib/SimpleSAML/Error/UnserializableException.php diff --git a/lib/SimpleSAML/Error/UnserializableException.php b/lib/SimpleSAML/Error/UnserializableException.php new file mode 100644 index 000000000..9798a29a1 --- /dev/null +++ b/lib/SimpleSAML/Error/UnserializableException.php @@ -0,0 +1,27 @@ +<?php + +/** + * Class for saving normal exceptions for serialization. + * + * This class is used by the SimpleSAML_Auth_State class when it needs + * to serialize an exception which doesn't subclass the + * SimpleSAML_Error_Exception class. + * + * It creates a new exception which contains the backtrace and message + * of the original exception. + * + * @package simpleSAMLphp + * @version $Id$ + */ +class SimpleSAML_Error_UnserializableException extends SimpleSAML_Error_Exception { + + public function __construct(Exception $original) { + + $msg = get_class($original) . ': ' . $original->getMessage(); + $code = $original->getCode(); + parent::__construct($msg, $code); + + $this->setBacktrace(SimpleSAML_Utilities::buildBacktrace($original)); + } + +} \ No newline at end of file -- GitLab