"Fatal error: Uncaught Error" in PHP — What It Means and How to Fix It

What the PHP error "Fatal error: Uncaught Error" means and how to fix it.

Published November 1, 2026

'Uncaught Error' is PHP 7+ throwing an Error exception that nothing caught, so the script stops. The text after 'Uncaught' names the specific error, which is what you need to fix.

What it means and why it happens

Errors (TypeError, ValueError, DivisionByZeroError, ArgumentCountError) extend Throwable and can be caught like exceptions, but most should be fixed rather than caught.

Read the full message: it names the file and line where the problem was detected, which is the best place to start.

What you see

run the code
Fatal error: Uncaught Error: Call to undefined method Foo::bar() in app.php:10 Stack trace: #0 {main} thrown

Practical examples

Code that triggers it

<?php
intdiv(1, 0);   // DivisionByZeroError never caught

The fix

<?php
try {
    echo intdiv(1, 0);
} catch (DivisionByZeroError $e) {
    echo 'Cannot divide by zero';
}

Global handler

set_exception_handler(function (Throwable $e) {
    error_log($e);
    http_response_code(500);
    echo 'Something went wrong';
});

Common mistakes

  • Catching Throwable to hide bugs.
  • Not reading the stack trace.
  • Displaying errors on production sites.

Key takeaways

  • Fatal error: Uncaught Error: 'Uncaught Error' is PHP 7+ throwing an Error exception that nothing caught, so the script stops.
  • Read the message and the line number first.
  • Fix the cause, don't just silence the error.

FAQ

Error vs Exception?

Both implement Throwable; Error is for engine-level problems.

How do I find which line caused Fatal error: Uncaught Error?

The error message and stack trace show the file and line; start there and work backwards.

More PHP articles