1

to sum it up: I've got an exception-class (\core\exceptions\GuruMeditationException) that extends from \Exception. Every other exception class simply extends from my own exception class. When my code runs and an exception is thrown everything works perfect for me.

Now: Assume I have a class (\app\HomeView) that extends from \core\base\mvc\View. Exceptions thrown in there are caught fine, too. The class declaration looks like this:

namespace app;
class HomeView extends \core\base\mvc\View {
}

But: If I do the following:

namespace app;
class HomeView extends \core\base\mvc\DoesNotExist {   # line 5
}

then no exception is caught anymore. I've already tried to catch all exceptions i created, with and without namespace. I also tried to catch 'Exception' and '\Exception' but nothing will help. Instead I get an error similar to that:

Fatal error: Class 'core\base\mvc\DoesNotExistView' not found in /var/www/abuhome/htdocs/test-namespace/class/HomeView.class.php on line 5

Call Stack:
0.0001     635104   1. {main}() /var/www/abuhome/htdocs/test-namespace/index.php:0
0.0135    1536280   2. core\Quantum->make() /var/www/abuhome/htdocs/test-namespace/index.php:36
0.0135    1540880   3. core\scriptlet\ProtocolScriptlet->dispatch() /home/equinox/qf-namespace/class/Quantum.class.php:124
0.0136    1540880   4. core\scriptlet\XhtmlScriptlet->dispatch() /home/equinox/qf-namespace/class/scriptlet/ProtocolScriptlet.class.php:39
0.0136    1540880   5. core\template\tpl\TplContainerParser->parseContainerFile() /home/equinox/qf-namespace/class/scriptlet/XhtmlScriptlet.class.php:22
0.0139    1564656   6. core\scriptlet\ContentScriptlet->executeSuitingRequestParameter() /home/equinox/qf-namespace/class/template/tpl/TplContainerParser.class.php:42
0.0139    1564656   7. core\scriptlet\ContentScriptlet->processMainContent() /home/equinox/qf-namespace/class/scriptlet/ContentScriptlet.class.php:145
0.0141    1573640   8. core\scriptlet\ContentScriptlet->processModule() /home/equinox/qf-namespace/class/scriptlet/ContentScriptlet.class.php:154
0.0143    1583808   9. include('/var/www/abuhome/htdocs/test-namespace/modules/home.php') /home/equinox/qf-namespace/class/scriptlet/ContentScriptlet.class.php:174
0.0143    1584248  10. uses() /var/www/abuhome/htdocs/test-namespace/modules/home.php:4
0.0151    1637696  11. require_once('/var/www/abuhome/htdocs/test-namespace/class/HomeView.class.php') /home/equinox/qf-namespace/functions/uses.function.php:49

Can anyone help me please? I think I've forgot something, but I can't figure out what it is >.<

thank you

2
  • @Phil The edit button is right there below the question... Commented Oct 14, 2011 at 13:15
  • 2
    @Juhana I'd rather Tristan learn from my comment Commented Oct 14, 2011 at 13:17

1 Answer 1

3

You cannot catch or stop fatal errors, they are fatal.

A syntax error is not an exceptional circumstance.

Sign up to request clarification or add additional context in comments.

6 Comments

hum ok. I don't think this is a syntax error - fatal, ok - but in my opinion this should be catchable =/
@TristanCebulla You can catch it via an autoloader if you really, really want to ;)
@TristanCebulla Perhaps "syntax error" is not entirely accurate. More of a compilation / parse error
i already have an autoloader (the uses() function), but that does not prevent from fatal typing errors when extending from a nonexistant class. or is there some namespace/autoload-magic i don't know?
@TristanCebulla What do you hope to achieve by catching an error like this? Your code can obviously not continue to be parsed as compilation will be impossible
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.