vendredi 9 février 2018

How to create an error page to a QueryException?

I'm working on a commercial application and I've created Blade files for several kinds of HTTP errors. They are placed in /resources/views/errors and are working fine for authorization (503.blade.php), page not found (404.blade.php), and so on.

I've created files for 400, 403, 404, 500 and 503, until now. The issue is when a QueryException is thrown. In this case, "Whoops, looks like something went wrong." appears.

For example, considering that name cannot be null, when I do something like this, Laravel throws a QueryException:

User::create([
          'name' => null,
          'email' => 'some@email.com'
]);

The exception would be:

QueryException in Connection.php line 651: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'name' cannot be null (SQL: insert into users (nome, email, updated_at, created_at) values (, some@email.com, 2018-02-09 12:10:50, 2018-02-09 12:10:50))

I don't want "Whoops, looks like something went wrong." to appear to the end user, I want to show a custom page. What kind of error file do I need to create to achieve this behavior?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire