file_get_contentsでException飛ばすメモ
<?php
try {
ob_start();
//warningが出るコード
$file = file_get_contents('./not_found_file.txt');
$warning = ob_get_contents();
ob_end_clean();
//Warningがあれば例外を投げる
if ($warning) {
throw new Exception($warning);
}
} catch (Exception $e) {
header("HTTP/1.0 500 Internal Server Error");
echo 'エラーが発生しました。<br>';
echo 'メッセージ:' . $e->getMessage() . '<br>';
echo '発生箇所:' . $e->getFile() . ' 行:' . $e->getLine() . '<br>';
echo 'デバッグ:' . '<br>';
echo $e->getTraceAsString() . '<br>';
}