Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[10.x] Make Vite throw a new ManifestNotFoundException #47681

Merged
merged 2 commits into from Jul 8, 2023
Merged

[10.x] Make Vite throw a new ManifestNotFoundException #47681

merged 2 commits into from Jul 8, 2023

Conversation

innocenzi
Copy link
Contributor

What

This pull request introduces a new ManifestNotFoundException that simply extends \Exception.
It's used instead of the base \Exception that is thrown when the Vite manifest cannot be found.

Why

I have specific exception handling in all my projects using Inertia or Hybridly: I don't want to display my custom error page for this error, since it won't be able to be rendered due to Vite not being started.

I currently use the following:

protected function shouldRenderInertiaResponse(Response $response, Request $request, \Throwable $e): bool
{
    if (str_contains($e->getMessage(), 'Vite manifest not found')) {
        return false;
    }

    if (app()->environment($this->skipHandlingInEnvironments())) {
        return false;
    }

    return \in_array($response->status(), $this->httpStatusesToHandle(), strict: true);
}

I believe having a specific exception would make this kind of logic more reliable. This is not specific to my projects' exception handling, it could also be used in Ignition as well, for instance.

@taylorotwell taylorotwell merged commit 8eb6ae8 into laravel:10.x Jul 8, 2023
16 checks passed
@innocenzi innocenzi deleted the refactor/vite-exception branch July 8, 2023 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants