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