Error Handling
The error.php file acts as a global safety net. When an unhandled exception occurs, this UI is rendered to prevent a white screen of death.
Core Utility: ErrorHandler
Prisma PHP uses the static ErrorHandler class to capture and display exceptions globally.
Read the ErrorHandler documentation →
Configuration Behavior
The content stored in ErrorHandler::$content changes based on your .env settings.
Contains the full stack trace and exception message. Useful for debugging.
Contains a generic "An error occurred" message (or your custom override) to prevent leaking system details.
Implementation
Use the PP\ErrorHandler class to output the exception message within your HTML structure.
<?php use PP\ErrorHandler; ?>
<div class="flex items-center justify-center min-h-screen">
<div class="text-center max-w-md">
<h1 class="text-6xl font-bold text-destructive">Oops!</h1>
<!-- Displays the error message -->
<p class="text-xl mt-4"><?= ErrorHandler::$content ?></p>
<div class="mt-6">
<a href="/" class="px-6 py-3 text-lg font-semibold bg-destructive text-destructive-foreground hover:bg-destructive/80 rounded-lg shadow-md">
Go Back Home
</a>
</div>
</div>
</div>