Welcome Guest, Not a member yet? Register   Sign In
Try catch is not working
#1

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?
Reply
#2

There is no add() method in the Model class. If you are trying to insert a row use insert() or update() or save() if updating existing records.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB