Development
One of the advantages to working with a robust server-side framework is the built-in exception handling you get for free. For example, Laravel ships with a beautiful error reporting tool which displays a nicely formatted stack trace in local development. The challenge is, if you’re making an XHR request (which Inertia does) and you hit a server-side error, you’re typically left digging through the network tab in your browser’s devtools to diagnose the problem. Inertia solves this issue by showing all non-Inertia responses in a modal. This means you get the same beautiful error-reporting you’re accustomed to, even though you’ve made that request over XHR.Dialog Element
By default, Inertia displays error modals using a custom<div> overlay. However, you can opt-in to using the native HTML <dialog> element instead, which provides built-in modal functionality including backdrop handling.
To enable this, configure the future.useDialogForErrorModal option in your application defaults.
Production
In production you will want to return a proper Inertia error response instead of relying on the modal-driven error reporting that is present during development. To accomplish this, you’ll need to update your framework’s default exception handler to return a custom error page. When building Laravel applications, you can accomplish this by using therespond exception method in your application’s bootstrap/app.php file.
ErrorPage page component in the example above. You’ll need to actually create this component, which will serve as the generic error page for your application. Here’s an example error component you can use as a starting point.