__construct() public method

Note that the cause will be converted to a SimpleSAML_Error_UnserializableException unless it is a subclass of SimpleSAML_Error_Exception.
public __construct ( string $message, integer $code, Exception $cause = null )
$message string Exception message
$code integer Error code
$cause Exception The cause of this exception.
コード例 #1
0
 /**
  * Constructor for the assertion exception.
  *
  * Should only be called from the onAssertion handler.
  *
  * @param string|NULL $assertion  The assertion which failed, or NULL if the assert-function was
  *                                given an expression.
  */
 public function __construct($assertion = NULL)
 {
     assert('is_null($assertion) || is_string($assertion)');
     $msg = 'Assertion failed: ' . var_export($assertion, TRUE);
     parent::__construct($msg);
     $this->assertion = $assertion;
 }
コード例 #2
0
 public function __construct(Exception $original)
 {
     $msg = get_class($original) . ': ' . $original->getMessage();
     $code = $original->getCode();
     parent::__construct($msg, $code);
     $this->setBacktrace(SimpleSAML_Utilities::buildBacktrace($original));
 }
コード例 #3
0
 /**
  * Constructor for this error.
  *
  * The error can either be given as a string, or as an array. If it is an array, the
  * first element in the array (with index 0), is the error code, while the other elements
  * are replacements for the error text.
  *
  * @param mixed $errorCode  One of the error codes defined in the errors dictionary.
  * @param Exception $cause  The exception which caused this fatal error (if any).
  */
 public function __construct($errorCode, Exception $cause = NULL)
 {
     assert('is_string($errorCode) || is_array($errorCode)');
     if (is_array($errorCode)) {
         $this->parameters = $errorCode;
         unset($this->parameters[0]);
         $this->errorCode = $errorCode[0];
     } else {
         $this->parameters = array();
         $this->errorCode = $errorCode;
     }
     $moduleCode = explode(':', $this->errorCode, 2);
     if (count($moduleCode) === 2) {
         $this->module = $moduleCode[0];
         $this->dictTitle = '{' . $this->module . ':errors:title_' . $moduleCode[1] . '}';
         $this->dictDescr = '{' . $this->module . ':errors:descr_' . $moduleCode[1] . '}';
     } else {
         $this->dictTitle = '{errors:title_' . $this->errorCode . '}';
         $this->dictDescr = '{errors:descr_' . $this->errorCode . '}';
     }
     if (!empty($this->parameters)) {
         $msg = $this->errorCode . '(';
         foreach ($this->parameters as $k => $v) {
             if ($k === 0) {
                 continue;
             }
             $msg .= var_export($k, TRUE) . ' => ' . var_export($v, TRUE) . ', ';
         }
         $msg = substr($msg, 0, -2) . ')';
     } else {
         $msg = $this->errorCode;
     }
     parent::__construct($msg, -1, $cause);
 }
コード例 #4
0
ファイル: Error.php プロジェクト: filonuse/fedlab
 /**
  * Constructor for this error.
  *
  * The error can either be given as a string, or as an array. If it is an array, the
  * first element in the array (with index 0), is the error code, while the other elements
  * are replacements for the error text.
  *
  * @param mixed $errorCode  One of the error codes defined in the errors dictionary.
  * @param Exception $cause  The exception which caused this fatal error (if any).
  */
 public function __construct($errorCode, Exception $cause = NULL)
 {
     assert('is_string($errorCode) || is_array($errorCode)');
     if (is_array($errorCode)) {
         $this->parameters = $errorCode;
         unset($this->parameters[0]);
         $this->errorCode = $errorCode[0];
     } else {
         $this->parameters = array();
         $this->errorCode = $errorCode;
     }
     if (!empty($this->parameters)) {
         $msg = $this->errorCode . '(';
         foreach ($this->parameters as $k => $v) {
             if ($k === 0) {
                 continue;
             }
             $msg .= var_export($k, TRUE) . ' => ' . var_export($v, TRUE) . ', ';
         }
         $msg = substr($msg, 0, -2) . ')';
     } else {
         $msg = $this->errorCode;
     }
     parent::__construct($msg, -1, $cause);
 }
コード例 #5
0
 /**
  * Create a serializable exception representing an unserializable exception.
  *
  * @param Exception $original  The original exception.
  */
 public function __construct(Exception $original)
 {
     $this->class = get_class($original);
     $msg = $original->getMessage();
     $code = $original->getCode();
     if (!is_int($code)) {
         /* PDOException uses a string as the code. Filter it out here. */
         $code = -1;
     }
     parent::__construct($msg, $code);
     $this->initBacktrace($original);
 }
コード例 #6
0
 /**
  * Create a SAML 2 error.
  *
  * @param string $status  The top-level status code.
  * @param string|NULL $subStatus  The second-level status code. Can be NULL, in which case there is no second-level status code.
  * @param string|NULL $statusMessage  The status message. Can be NULL, in which case there is no status message.
  * @param Exception|NULL $cause  The cause of this exception. Can be NULL.
  */
 public function __construct($status, $subStatus = NULL, $statusMessage = NULL, Exception $cause = NULL)
 {
     assert('is_string($status)');
     assert('is_null($subStatus) || is_string($subStatus)');
     assert('is_null($statusMessage) || is_string($statusMessage)');
     $st = self::shortStatus($status);
     if ($subStatus !== NULL) {
         $st .= '/' . self::shortStatus($subStatus);
     }
     if ($statusMessage !== NULL) {
         $st .= ': ' . $statusMessage;
     }
     parent::__construct($st, 0, $cause);
     $this->status = $status;
     $this->subStatus = $subStatus;
     $this->statusMessage = $statusMessage;
 }