laravel has best error handling code example
Example 1: laravel handle queryexception
try {
$this->model->create($data);
} catch (Illuminate\Database\QueryException $e) {
dd($e);
} catch (PDOException $e) {
dd($e);
}
Example 2: how to hide error in laravel
Go inside env file :
APP_DEBUG=true
if you didn't find it go to config/app.php :
'debug' => false,