Answer the question
In order to leave comments, you need to log in
Fatal error: Uncaught exception what to do?
Good afternoon, I'm just starting to learn all the delights of programming. And going through the next video lesson, I wanted to repeat the example that is indicated in it, but I got a Fatal error at the output and I just can’t understand what the reason is. Please help me because I can't continue learning until the code
works Fatal error: Uncaught exception 'core\base\exceptions\RouteException' with message 'Error' in D:\OSpanel\OSPanel\domains\Test.com\index.php: 43 Stack trace: #0 D:\OSpanel\OSPanel\domains\Test.com\index.php(36): C->__construct() #1 D:\OSpanel\OSPanel\domains\Test.com\index.php (29): B->__construct() #2 D:\OSpanel\OSPanel\domains\Test.com\index.php(19): A->__construct() #3 {main} thrown in D:\OSpanel\ OSPanel\domains\Test.com\index.php on line 43
Here is the code itself
use core\base\exceptions\RouteException;
try {
(new A());
}
catch (RangeException $e) {
exit($e->getMessage());
}
class A
{
public function __construct()
{
(new B());
}
}
class B
{
public function __construct()
{
(new C());
}
}
class C
{
public function __construct()
{
throw new RouteException('Ошибка');
}
}
Answer the question
In order to leave comments, you need to log in
You need to catch the same error (RouteException) or a common one (Exception)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question