__construct() public method

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.
public __construct ( mixed $errorCode, Exception $cause = null, integer | null $httpCode = null )
$errorCode mixed One of the error codes defined in the errors dictionary.
$cause Exception The exception which caused this fatal error (if any). Optional.
$httpCode integer | null The HTTP response code to use. Optional.
Ejemplo n.º 1
0
 /**
  * Create a new BadRequest error.
  *
  * @param string $reason  Description of why the request was unacceptable.
  */
 public function __construct($reason)
 {
     assert('is_string($reason)');
     $this->reason = $reason;
     parent::__construct(array('BADREQUEST', '%REASON%' => $this->reason));
     $this->httpCode = 400;
 }
Ejemplo n.º 2
0
 /**
  * Create a new AuthSource error.
  *
  * @param string $authsource  Authsource module name from where this error was thrown.
  * @param string $reason  Description of the error.
  */
 public function __construct($authsource, $reason, $cause = NULL)
 {
     assert('is_string($authsource)');
     assert('is_string($reason)');
     $this->authsource = $authsource;
     $this->reason = $reason;
     parent::__construct(array('AUTHSOURCEERROR', '%AUTHSOURCE%' => htmlspecialchars(var_export($this->authsource, TRUE)), '%REASON%' => htmlspecialchars(var_export($this->reason, TRUE))), $cause);
 }
Ejemplo n.º 3
0
 /**
  * Create a new NotFound error
  *
  * @param string $reason  Optional description of why the given page could not be found.
  */
 public function __construct($reason = NULL)
 {
     assert('is_null($reason) || is_string($reason)');
     $url = SimpleSAML_Utilities::selfURL();
     if ($reason === NULL) {
         parent::__construct(array('NOTFOUND', '%URL%' => $url));
     } else {
         parent::__construct(array('NOTFOUNDREASON', '%URL%' => $url, '%REASON%' => $reason));
     }
     $this->reason = $reason;
 }
Ejemplo n.º 4
0
 /**
  * Create a new NotFound error
  *
  * @param string $reason  Optional description of why the given page could not be found.
  */
 public function __construct($reason = NULL)
 {
     assert('is_null($reason) || is_string($reason)');
     $url = \SimpleSAML\Utils\HTTP::getSelfURL();
     if ($reason === NULL) {
         parent::__construct(array('NOTFOUND', '%URL%' => $url));
     } else {
         parent::__construct(array('NOTFOUNDREASON', '%URL%' => $url, '%REASON%' => $reason));
     }
     $this->reason = $reason;
     $this->httpCode = 404;
 }
Ejemplo n.º 5
0
 /**
  * Create a new NotFound error
  *
  * @param string $reason  Optional description of why the given page could not be found.
  */
 public function __construct($reason = NULL)
 {
     assert('is_null($reason) || is_string($reason)');
     $url = \SimpleSAML\Utils\HTTP::getSelfURL();
     if ($reason === NULL) {
         parent::__construct(array('NOTFOUND', '%URL%' => $url));
         $this->message = "The requested page '{$url}' could not be found.";
     } else {
         parent::__construct(array('NOTFOUNDREASON', '%URL%' => $url, '%REASON%' => $reason));
         $this->message = "The requested page '{$url}' could not be found. " . $reason;
     }
     $this->reason = $reason;
     $this->httpCode = 404;
 }
 /**
  * ConfigurationError constructor.
  *
  * @param string|null $reason The reason for this exception.
  * @param string|null $file The configuration file that originated this error.
  * @param array|null $config The configuration array that led to this problem.
  */
 public function __construct($reason = null, $file = null, array $config = null)
 {
     $file_str = '';
     $reason_str = '.';
     $params = array('CONFIG');
     if ($file !== null) {
         $params['%FILE%'] = $file;
         $basepath = dirname(dirname(dirname(dirname(__FILE__)))) . '/';
         $file_str = '(' . str_replace($basepath, '', $file) . ') ';
     }
     if ($reason !== null) {
         $params['%REASON%'] = $reason;
         $reason_str = ': ' . $reason;
     }
     $this->reason = $reason;
     $this->config_file = $file;
     parent::__construct($params);
     $this->message = 'The configuration ' . $file_str . 'is invalid' . $reason_str;
 }
Ejemplo n.º 7
0
 /**
  * Create the error
  */
 public function __construct()
 {
     $this->includeTemplate = 'core:no_state.tpl.php';
     parent::__construct('NOSTATE');
 }
Ejemplo n.º 8
0
 /**
  * Create the error
  *
  * @param string $entityId  The entityID we were unable to locate.
  */
 public function __construct($entityId)
 {
     assert('is_string($entityId)');
     $this->includeTemplate = 'core:no_metadata.tpl.php';
     parent::__construct(array('METADATANOTFOUND', '%ENTITYID%' => htmlspecialchars(var_export($entityId, TRUE))));
 }
Ejemplo n.º 9
0
 /**
  * Create the error
  *
  * @param Exception|NULL $cause  The exception that caused this error.
  */
 public function __construct(Exception $cause = NULL)
 {
     parent::__construct('USERABORTED', $cause);
 }
Ejemplo n.º 10
0
 /**
  * Create the error
  *
  * @param string $entityId  The entityID we were unable to locate.
  */
 public function __construct($entityId)
 {
     assert('is_string($entityId)');
     parent::__construct('Unable to locate metadata for ' . var_export($entityId, TRUE) . '.');
     $this->entityId = $entityId;
 }
Ejemplo n.º 11
0
 /**
  * Create the error
  *
  * @param string $reason  Optional description of why the given page could not be found.
  */
 public function __construct()
 {
     parent::__construct('State information lost, and no way to restart the request.');
 }
 /**
  * Create the error
  *
  * @param string $entityId  The entityID we were unable to locate.
  */
 public function __construct($entityId)
 {
     assert('is_string($entityId)');
     parent::__construct(array('METADATANOTFOUND', 'ENTITYID' => htmlspecialchars(var_export($entityId, TRUE))));
     $this->entityId = $entityId;
 }
Ejemplo n.º 13
0
 /**
  * Create the error
  */
 public function __construct()
 {
     parent::__construct('NOSTATE');
 }