0

I'm looking for any way to handle the QueryException using the laravel framework.

Is there any possible way to prevent the usual user from getting such an error with a handler?

I tried to prevent that black detailed error page not to be visible to any user.

Mohamed Mahfouz
  • 174
  • 1
  • 4
  • 11

1 Answers1

1

Catch an exception on using try-catch statements :

Use Exception;

try
{
   // write your codes here
}
catch(\Exception $e)
{
   //dd($e->getMessage());
   return "Something Went Wrong";
}

If you want to catch PDO Exception :

use PDOException;

try
{
   //write your codes here
} 
catch(\PDOException $e)
{
   //dd($e->getMessage());
   return "Something Went Wrong":
}
sta
  • 24,192
  • 8
  • 39
  • 53