This is quite an old thread, but still... it describes EXACTLY the problem I'm facing now and I can't figure it out.
use Illuminate\Database\QueryException;
try {
$newuser = new User();
$newuser->save();
return response()->json(null, 200);
} catch (QueryException $e) {
$message = "Error";
return response()->json($message, 500);
}
I get :
{
"message": "SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'last_name' cannot be null (SQL: insert into `users` ... ",
"exception": "Illuminate\Database\QueryException",
...
}
btw: catch (Exception $e) also doesn't work
i.e: the exception isn't caught.
It's driving me nuts, help please !