LoginSignup
122
122

More than 5 years have passed since last update.

PHP標準例外まとめ

Last updated at Posted at 2013-08-21

参考 PHP公式:例外

PHP定義済み例外

Exception

すべての基底となる例外クラス。
PHPはException型以外のオブジェクト、値をthrowできません。
javascriptが異常なだけです。

ErrorExcetption

エラー例外。
変換用ロジックはこちら

function exception_error_handler($errno, $errstr, $errfile, $errline ) {
    throw new ErrorException($errstr, $errno, 0, $errfile, $errline);
}
set_error_handler("exception_error_handler");

protected $severityでエラー番号が取得可能とか。

SPL例外

LogicException

 ロジック内部でのエラーを表す例外。コード異常を示し,修正を促す。

BadFunctionCallException

 未定義関数のコールバックや、引数異常を示す例外

BadMethodCallException

 BadFunctionCallExceptionのメソド版

DomainException

 定義されたデータドメインに対する不適合を示す例外

InvalidArgumentException

 引数が期待する形式と一致しなかったことを示す例外

LengthException

 データ長エラーを示す例外

OutOfRangeException

 無効なインデックス要求に対する例外

RuntimeException

 実行時にのみ検出可能な例外。

OutOfBoundsException

 値が有効なキーでなかった場合にスローされる例外

OverflowException

 上限となるコンテナへのデータ追加で生じる例外

RangeException

 範囲エラーを示す例外。DomainExceptionの実行時版

UnderflowException

 空のコンテナに対する削除操作等を示す例外

UnexpectedValueException

 期待した値と一致しないことを示す例外

ざっくり

122
122
5

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
122
122