Skip to content
Snippets Groups Projects
Commit 1768481f authored by Olav Morken's avatar Olav Morken
Browse files

SimpleSAML_Error_Exception: Add fromException().

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2484 44740490-163a-0410-bde0-09ae8108e29a
parent b311f5e4
No related branches found
No related tags found
No related merge requests found
...@@ -49,11 +49,23 @@ class SimpleSAML_Error_Exception extends Exception { ...@@ -49,11 +49,23 @@ class SimpleSAML_Error_Exception extends Exception {
$this->backtrace = SimpleSAML_Utilities::buildBacktrace($this); $this->backtrace = SimpleSAML_Utilities::buildBacktrace($this);
if ($cause !== NULL) { if ($cause !== NULL) {
if (!($cause instanceof SimpleSAML_Error_Exception)) { $this->cause = SimpleSAML_Error_Exception::fromException($cause);
$cause = new SimpleSAML_Error_UnserializableException($cause); }
} }
$this->cause = $cause;
/**
* Convert any exception into a SimpleSAML_Error_Exception.
*
* @param Exception $e The exception.
* @return SimpleSAML_Error_Exception The new exception.
*/
public static function fromException(Exception $e) {
if ($e instanceof SimpleSAML_Error_Exception) {
return $e;
} }
return new SimpleSAML_Error_UnserializableException($e);
} }
......
...@@ -44,9 +44,7 @@ foreach ($sets AS $setkey => $set) { ...@@ -44,9 +44,7 @@ foreach ($sets AS $setkey => $set) {
break; break;
} }
} catch (Exception $e) { } catch (Exception $e) {
if (! $e instanceof SimpleSAML_Error_Exception) { $e = SimpleSAML_Error_Exception::fromException($e);
$e = new SimpleSAML_Error_UnserializableException($e);
}
$e->logWarning(); $e->logWarning();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment