I would,like to display an error if saving fails
I have currently this
public function submit()
{
$validatedData = $this->validate();
DB::beginTransaction();
try
{
$this->globalSettings->update(['wordcount' => $validatedData['read_per_minute'] ]);
DB::commit();
Session::flash('success', 'Your settings have been saved Successfully');
} catch (exception $e) {
DB::rollback();
Session::flash('fail', 'An error occured');
}
}
To trigger my error, I changed the database field name before saving and set the APP_DEBUGto false in .env.
When APP_DEBUG is set to true, I get the mysql error in a popup
When APP_DEBUG is set to false, I get an error 500 popup
Is there a way to avoid these popups, get the error caught by the try/catch, and display the relevant message?