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
  • 201
  • 1
  • 5
  • 14

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
  • 30,729
  • 8
  • 45
  • 59