Uncaught Exception 🐘 PHP

Fatal error: Uncaught Exception: message in file.php:12

An exception was thrown and nothing caught it, so PHP stopped the script.

Seen on: PHP

Meaning

The message after “Uncaught Exception:” is the real error, followed by the file/line and a stack trace. Frameworks normally catch these and show an error page; plain scripts don’t.

Common causes

  • Exception thrown in your code or a library with no try/catch
  • Exception thrown in a destructor or shutdown function
  • Missing global exception handler

⚡ Quick fix

  1. Read the message and the first stack frame in your code
  2. Catch expected exceptions where you can handle them
  3. Register set_exception_handler() to log and show a friendly page

Detailed fix by platform

PHP

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

How to diagnose

  1. Message — What does it say?
  2. Origin — First frame in your code

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.