0

When my script fails in a Laravel 9 app, instead of it to outputing the JSON I configured, it shows this:

InvalidArgumentException: View [welcome] not found. in file C:\Users\kgl\Documents\biomandate\secure\vendor\laravel\framework\src\Illuminate\View\FileViewFinder.php on line 137

I think I need to adjust the App\Exceptions handler but somehow I still have error. Please how do I fix this?

For example: if the below code fails, I need the response to be something I have configured.

$user = new User();
$user->name = $validatedData['name'];
$user->email = $validatedData['email'];
$user->password = Hash::make($validatedData['password']);
$user->token = $token;
$user->save()
7
  • The error is telling you that a view called 'Welcome' was not found. Do you expect this view to exist? Do you know anything about this view? Commented May 29, 2023 at 18:02
  • No i do not need that view i just want to return my own response if it fails. how do i disable Laravel's default exception handling from taking over. Commented May 29, 2023 at 18:25
  • Let me ask it slightly differently then. Would you like to remove the reference to the Welcome view? It's unclear to me at this point whether your question seeks to get through an error, or whether you want to implement a custom error handler. Commented May 29, 2023 at 18:36
  • There are soooo many ways to answer your question, but 'view not found' is actually the wrong question. Without answering your question, go to Exceptions/Handler.php, there's a render function. Loop through possible variations of the Exception, InvalidArgumentException is one of them. Let's say you do a match on the Exception. If it's that InvalidArgumentException then handle it by .... showing a 404 not found page? Commented May 29, 2023 at 19:00
  • @LajosArpad yes i want to implement a custom error handler so that when save() is not successful let me return a clearer error Commented May 29, 2023 at 19:10

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.