SimpleSAML_Error_Exception::fromException PHP Method

fromException() public static method

Convert any exception into a SimpleSAML_Error_Exception.
public static fromException ( Exception $e ) : SimpleSAML_Error_Exception
$e Exception 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);
    }

Usage Example

示例#1
0
 /**
  * Constructor for this error.
  *
  * Note that the cause will be converted to a SimpleSAML_Error_UnserializableException unless it is a subclass of
  * SimpleSAML_Error_Exception.
  *
  * @param string         $message Exception message
  * @param int            $code Error code
  * @param Exception|null $cause The cause of this exception.
  */
 public function __construct($message, $code = 0, Exception $cause = null)
 {
     assert('is_string($message)');
     assert('is_int($code)');
     parent::__construct($message, $code);
     $this->initBacktrace($this);
     if ($cause !== null) {
         $this->cause = SimpleSAML_Error_Exception::fromException($cause);
     }
 }
All Usage Examples Of SimpleSAML_Error_Exception::fromException