/**
  * @param integer|\SplInt|string|\SplString $codeOrName
  * @param string $name
  * @dataProvider codeProvider
  */
 public function testGetCode($codeOrName, $name)
 {
     $exception = new DOMException('error message', $codeOrName);
     $this->assertSame($name, $exception->code);
     $this->assertSame($name, $exception->getCode());
 }
Exemple #2
0
 /**
  * @param string $message The exception message to throw,
  *      which is an optional, that provides human readable details of the exception.
  * @param string|integer $code The error name, a string, which is the type of error the exception represents.
  * @param \Exception $previous The previous exception used for the exception chaining.
  */
 public function __construct($message, $code, \Exception $previous = null)
 {
     parent::__construct($message, 0, $previous);
     $name = array_search($code, self::$errorNamesAndLegacyIntegerCodeValues);
     $this->code = $name && self::$errorNamesAndLegacyIntegerCodeValues[$name] ? $name : (string) $code;
 }