PHPではエラーが発生するときに呼び出すfunctionをset_error_handlerで設定できます。
まだまだPHPでtry-catch方式でエラーハンドリングを行っている方は少ないと予想していますが、
try-catchで統一するための方法が以下にありました。
function errorHandler($errno, $errstr, $errfile, $errline) {
throw new Exception($errstr, $errno);
}
set_error_handler('errorHandler');
try {
file_put_contents('cosmos:\\1.txt', 'asdf');
} catch (Exception $e) {
echo $e->getMessage();
}
これで、PHPのエラーが起きたときに例外を発生させることが可能です。