Reputation: 10228
When I use this code in Laravel framework:
throw new Exception("failed");
it throws this error:
FatalErrorException in MyController.php line 178: Class 'App\Http\Controllers\Exception' not found
Does anybody know how can I use
(include
) that Exception
class to my controller? Where is actually it?
Upvotes: 17
Views: 28468
Reputation: 1582
Throw the exception using the following code.
throw new \Exception("failed");
Otherwise, import the class before using.
use Exception;
Upvotes: 46