Im trying to catch errors when data is not inserted on the database.
This is may code:
try {
$id = (new CatalogModel)->create([
'role' => post('role'),
'title' => post('title'),
]);
model('App\Models\ActivityLogModel')->add('Se ha creado un nuevo grupo: '.$id.' Creado por: '.logged('name'), logged('id'));
} catch (\Exception $e) {
model('App\Models\ActivityLogModel')->add('Error al crear grupos:'. $e->errorMessage(), logged('id'));
}
But its not working and allways redirect to error page (errors/html/production.php).
Any help on this?