Petru Lebada
Petru Lebada

Reputation: 1682

Class not found if throw a different exception name

I get a

Fatal error: Class 'AException' not found in

when I throw an exception with a different name than 'Exception':

try
{
  if ( something ) throw new AException('Error');
}
catch (AException $e)
{
  $e->getMessage();
}

But if I change AException with Exception it works. Any help please?

Upvotes: 0

Views: 94

Answers (1)

Bert
Bert

Reputation: 2456

You need to create a class for every custom exception.

ref: http://php.net/manual/en/language.exceptions.extending.php

Upvotes: 1

Related Questions