laravel Error Class ‘App\Http\Controllers\Exception’ not found
问题
throw new Exception('ok');
解决
用这个php自带的\Exception
throw new \Exception("ok");
try {
throw new \Exception('ok');
} catch (\Exception $e) {
echo $e->getMessage();
}
或者
先在类前面引入use Exception
use Exception;
try {
throw new Exception('ok');
} catch (Exception $e) {
echo $e->getMessage();
}
参考:
https://stackoverflow.com/questions/41415095/exception-class-not-found-in-laravel