コード例 #1
0
ファイル: Exception.php プロジェクト: rzajac/phptools
 /**
  * Creates ApiException from any other exception.
  *
  * @param \Exception $e            The original exception.
  * @param null       $overrideCode The code to override.
  *
  * @return static
  */
 public static function makeFromException($e, $overrideCode = null)
 {
     $code = $overrideCode === null ? $e->getCode() : $overrideCode;
     if ($e instanceof static) {
         $e->code = $code;
         return $e;
     }
     return new static($e->getMessage(), $code, $e);
 }
コード例 #2
0
ファイル: Exception_Test.php プロジェクト: rzajac/phptools
 /**
  * @covers ::spf
  */
 public function test_spf()
 {
     // When
     $e = Exception::spf('Something %s created %d errors.', 'awful', 666);
     // Then
     $this->assertSame('Something awful created 666 errors.', $e->getMessage());
 }