diff --git a/lib/SimpleSAML/Error/Exception.php b/lib/SimpleSAML/Error/Exception.php index fb8b62a1cdc0b4f4015b780147e8bfc0c888c7c3..761665ae301c09f89afc4029d1d969756b940872 100644 --- a/lib/SimpleSAML/Error/Exception.php +++ b/lib/SimpleSAML/Error/Exception.php @@ -49,11 +49,23 @@ class SimpleSAML_Error_Exception extends Exception { $this->backtrace = SimpleSAML_Utilities::buildBacktrace($this); if ($cause !== NULL) { - if (!($cause instanceof SimpleSAML_Error_Exception)) { - $cause = new SimpleSAML_Error_UnserializableException($cause); - } - $this->cause = $cause; + $this->cause = SimpleSAML_Error_Exception::fromException($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); } diff --git a/modules/metarefresh/www/fetch.php b/modules/metarefresh/www/fetch.php index 70f0ba0091623e4f75f14cc14ec88ddc7d9af6d4..f268cb9fc5b0900d1e0316240cfec6bc365ec124 100644 --- a/modules/metarefresh/www/fetch.php +++ b/modules/metarefresh/www/fetch.php @@ -44,9 +44,7 @@ foreach ($sets AS $setkey => $set) { break; } } catch (Exception $e) { - if (! $e instanceof SimpleSAML_Error_Exception) { - $e = new SimpleSAML_Error_UnserializableException($e); - } + $e = SimpleSAML_Error_Exception::fromException($e); $e->logWarning(); }