First, the insert() method returns false on an error, so you can start by checking the returned value. Then, you can check the $error['code'] value and redirect to instruments/duplicate if it matches your error code. If you haven't redirected yet, you can return the $error['message'] if it is set. Finally, you can redirect to instruments/addFail, since you have no other options in your original code.
PHP Code:
if ($this->db->insert('instrument', $data)) {
redirect('instruments/addSuccess');
}
$error = $this->db->error();
if ($error['code'] == 1062) {
redirect('instruments/duplicate');
}
if (isset($error['message'])) {
return $error['message'];
}
redirect('instruments/addFail');