Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Exception in the Module
  • Hello there,

    I have question regarding exception in the module.

    It seems to me that I cannot use Exception in the module.

    I am getting following.

    Fatal Error - Class 'Test\Exception' not found

    To throw an Exception, Do I have to use HttpServerErrorException written in the document?

    Regards,
  • HarroHarro
    Accepted Answer
    Of course you can, as long as you take into account the namespaces your current class is in, and the namespace your exception class is in.

    Assuming, with the little info you have given, that "Test" is the namespace of your module, and "Exception" is the standard PHP exception class, you need to use

    throw new \Exception('load this from the global namespace');

    If you don't add the leading backslash, PHP will try to find the class in the current namespace, where it doesn't exist.

  • Oh...yes.

    Thanks a lot.

    I will check that out.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion