Results of 1 - 2 of about 2 for MyCustomException (0.001 sec.)
- 前の例外(Throwable)を返す 9357
- « Exception::getMessage Exception::getCode » PHP Manual Exception 前の例外(Throwable)を返す 検索 Exception::getPrevious (PHP 5 >= 5.3.0, PHP 7, PHP 8) Exception::getPrevious — 前の例外(Throwable)を返す 説明 final public function Exception::
... れが存在しない場合は null を返します。 例 例1 Exception::getPrevious() の例 例外トレースをループし、表示します。 <?php class MyCustomException extends Exception {} function doStuff () { try { throw new InvalidArgumentException ( "You are doing it wrong!" , 112 ); } ... catch( Exception $e ) { throw new MyCustomException ( "Something happened" , 911 , $e ); } } try { doStuff (); } catch( Exception $e ) { do { printf ( "%s:%d %s (%d) [%s]\n" ... $e -> getPrevious ()); } ?> 上の例の出力は、 たとえば以下のようになります。 /home/bjori/ex.php:8 Something happened (911) [MyCustomException] /home/bjori/ex.php:6 You are doing it wrong! (112) [InvalidArgumentException] 参考 Throwable::getPrevious() - ひとつ前の ...
-
https://man.mtool.work/php/8.3/exception.getprevious.html
- 前の例外(Throwable)を返す 9357
- « Exception::getMessage Exception::getCode » PHP Manual Exception 前の例外(Throwable)を返す 検索 Exception::getPrevious (PHP 5 >= 5.3.0, PHP 7, PHP 8) Exception::getPrevious — 前の例外(Throwable)を返す 説明 final public function Exception::
... れが存在しない場合は null を返します。 例 例1 Exception::getPrevious() の例 例外トレースをループし、表示します。 <?php class MyCustomException extends Exception {} function doStuff () { try { throw new InvalidArgumentException ( "You are doing it wrong!" , 112 ); } ... catch( Exception $e ) { throw new MyCustomException ( "Something happened" , 911 , $e ); } } try { doStuff (); } catch( Exception $e ) { do { printf ( "%s:%d %s (%d) [%s]\n" ... $e -> getPrevious ()); } ?> 上の例の出力は、 たとえば以下のようになります。 /home/bjori/ex.php:8 Something happened (911) [MyCustomException] /home/bjori/ex.php:6 You are doing it wrong! (112) [InvalidArgumentException] 参考 Throwable::getPrevious() - ひとつ前の ...
-
https://man.mtool.work/php/8.3/exception.getprevious.html
PREV
1
NEXT