0

I want to manage several exceptions types. Each exception is just a defined classs, no more.

So, instead of having 5 files with empty class definition, I would like to group all exception of the same type in the same file.

Like that:

File: InvitationException.php

<?php

namespace App\Exceptions;

class InvitationExpiredException extends \Exception
{


}
class InvitationNeededException extends \Exception
{


}
class InvitationNotActiveException extends \Exception
{


}

But in my code, when I try to throw a new exception:

if (is_null($invite)) throw new  App\Exceptions\InvitationNeededException();

I get:

Fatal error: Class 'App\Exceptions\InvitationNeededException' not found

Why is it happening???

EDIT: Duplicated, but the real duplicated is the link provided by xdevnull:

Community
  • 1
  • 1
Juliatzin
  • 18,455
  • 40
  • 166
  • 325

0 Answers0