stack
stack

Reputation: 10228

Exception class not found in Laravel

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

Answers (1)

shoieb0101
shoieb0101

Reputation: 1582

Throw the exception using the following code.

throw new \Exception("failed");

Otherwise, import the class before using.

use Exception;

Upvotes: 46

Related Questions