diff --git a/lib/SimpleSAML/Error/UnserializableException.php b/lib/SimpleSAML/Error/UnserializableException.php
new file mode 100644
index 0000000000000000000000000000000000000000..9798a29a1b25098dda16c0b3b61ac21ae0a405d9
--- /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