Skip to content

Commit

Permalink
Catch Horde_Mongo_Exception
Browse files Browse the repository at this point in the history
  • Loading branch information
mrubinsk committed Nov 14, 2013
1 parent facf7da commit eaa3990
Showing 1 changed file with 31 additions and 31 deletions.
62 changes: 31 additions & 31 deletions framework/ActiveSync/lib/Horde/ActiveSync/State/Mongo.php
Expand Up @@ -154,7 +154,7 @@ class Horde_ActiveSync_State_Mongo extends Horde_ActiveSync_State_Base implement
* Const'r
*
* @param array $params Must contain:
* - connection: (Horde_Mongo_Client The Horde_Db instance.
* - connection: (Horde_Mongo_Client The Horde_Mongo instance.
*
* @return Horde_ActiveSync_State_Sql
*/
Expand Down Expand Up @@ -194,7 +194,7 @@ public function updateServerIdInState($uid, $serverid)

try {
$cursor = $this->_db->HAS_state->find($query, array('sync_data'));
} catch (Exception $e) {
} catch (Horde_Mongo_Exception $e) {
$this->_logger->err(sprintf(
'[%s] %s',
$this->_procid,
Expand All @@ -213,7 +213,7 @@ public function updateServerIdInState($uid, $serverid)
array('$set' => array('sync_data' => $folder)),
array('multiple' => true)
);
} catch (Exception $e) {
} catch (Horde_Mongo_Exception $e) {
$this->_logger->err(sprintf(
'[%s] %s',
$this->_procid,
Expand All @@ -239,7 +239,7 @@ protected function _loadState($type)
$results = $this->_db->HAS_state->findOne(
array('_id' => $this->_syncKey),
array('sync_data', 'sync_devid', 'sync_mod', 'sync_pending'));
} catch (Exception $e) {
} catch (Horde_Mongo_Exception $e) {
$this->_logger->err('Error in loading state from DB: ' . $e->getMessage());
throw new Horde_ActiveSync_Exception($e);
}
Expand Down Expand Up @@ -334,7 +334,7 @@ public function save()
serialize($document)));
try {
$this->_db->HAS_state->insert($document);
} catch (Exception $e) {
} catch (Horde_Mongo_Exception $e) {
// Might exist already if the last sync attempt failed.
$this->_logger->notice(
sprintf('[%s] Error saving state for synckey %s: %s - removing previous sync state and trying again.',
Expand All @@ -344,7 +344,7 @@ public function save()
try {
$this->_db->HAS_state->remove(array('_id' => $this->_syncKey));
$this->_db->HAS_state->insert($document);
} catch (Exception $e) {
} catch (Horde_Mongo_Exception $e) {
throw new Horde_ActiveSync_Exception('Error saving state.');
}
}
Expand Down Expand Up @@ -441,7 +441,7 @@ public function updateState(
}
try {
$this->_db->HAS_mailmap->insert($document);
} catch (Exception $e) {
} catch (Horde_Mongo_Exception $e) {
throw Horde_ActiveSync_Exception($e);
}
break;
Expand All @@ -460,7 +460,7 @@ public function updateState(

try {
$this->_db->HAS_map->insert($document);
} catch (Horde_Db_Exception $e) {
} catch (Horde_Mongo_Exception $e) {
throw new Horde_ActiveSync_Exception($e);
}
break;
Expand Down Expand Up @@ -526,7 +526,7 @@ public function loadDeviceInfo($devId, $user = null)

try {
$device_data = $this->_db->HAS_device->findOne($query);
} catch (Exception $e) {
} catch (Horde_Mongo_Exception $e) {
$this->_logger->err($e->getMessage());
throw new Horde_ActiveSync_Exception($e);
}
Expand Down Expand Up @@ -582,7 +582,7 @@ public function setDeviceInfo(Horde_ActiveSync_Device $data, array $dirty = arra
array('$set' => $device),
array('upsert' => true)
);
} catch (Exception $e) {
} catch (Horde_Mongo_Exception $e) {
$this->_logger->err($e->getMessage());
throw new Horde_ActiveSync_Exception($e);
}
Expand All @@ -603,7 +603,7 @@ public function setDeviceInfo(Horde_ActiveSync_Device $data, array $dirty = arra
array('_id' => $data->id),
array('$addToSet' => array('users' => $user_data))
);
} catch (Exception $e) {
} catch (Horde_Mongo_Exception $e) {
$this->_logger->err($e->getMessage());
throw new Horde_ActiveSync_Exception($e);
}
Expand Down Expand Up @@ -632,7 +632,7 @@ public function setDeviceProperties(array $data, $deviceId)
);
try {
$this->_db->HAS_device->update($query, $update);
} catch (Exception $e) {
} catch (Horde_Mongo_Exception $e) {
$this->_logger->err($e->getMessage());
throw new Horde_ActiveSync_Exception($e);
}
Expand All @@ -658,7 +658,7 @@ public function deviceExists($devId, $user = null)

try {
return $this->_db->HAS_device->find($query)->limit(1)->count();
} catch (Exception $e) {
} catch (Horde_Mongo_Exception $e) {
$this->_logger->err($e->getMessage());
throw new Horde_ActiveSync_Exception($e);
}
Expand All @@ -681,7 +681,7 @@ public function listDevices($user = null)
}
try {
$cursor = $this->_db->HAS_device->find($query);
} catch (Exception $e) {
} catch (Horde_Mongo_Exception $e) {
$this->_logger->err($e->getMessage());
throw new Horde_ActiveSync_Exception($e);
}
Expand Down Expand Up @@ -719,7 +719,7 @@ public function resetAllPolicyKeys()
// array('$set' => array('users.device_policykey' => 0)),
// array('multiple' => true)
// );
// } catch (Exception $e) {
// } catch (Horde_Mongo_Exception $e) {
// $this->_logger->err($e->getMessage());
// throw new Horde_ActiveSync_Exception($e);
// }
Expand Down Expand Up @@ -753,7 +753,7 @@ public function setDeviceRWStatus($devId, $status)
$update = array('$set' => $new_data);
try {
$this->_db->HAS_device->update($query, $update);
} catch (Exception $e) {
} catch (Horde_Mongo_Exception $e) {
$this->_logger->err($e->getMessage());
throw new Horde_ActiveSync_Exception($e);
}
Expand Down Expand Up @@ -786,7 +786,7 @@ protected function _resetDeviceState($id)
$this->_db->HAS_state->remove($query);
$this->_db->HAS_map->remove($query);
$this->_db->HAS_mailmap->remove($query);
} catch (Exception $e) {
} catch (Horde_Mongo_Exception $e) {
$this->_logger->err($e->getMessage());
throw new Horde_ActiveSync_Exception($e);
}
Expand Down Expand Up @@ -835,7 +835,7 @@ public function getLastSyncTimestamp($id = null, $user = null)
array('$match' => $match),
array('$group' => array('_id' => '$sync_dev', 'max' => array('$max' => '$sync_timestamp')))
);
} catch (Exception $e) {
} catch (Horde_Mongo_Exception $e) {
$this->_logger->err(sprintf(
'[%s] %s',
$this->_procid,
Expand Down Expand Up @@ -906,7 +906,7 @@ public function removeState(array $options)
);
try {
$results = $this->_db->HAS_device->findOne($query, array('_id'));
} catch (Exception $e) {
} catch (Horde_Mongo_Exception $e) {
$this->_logger->err(sprintf(
'[%s] %s',
$this->_procid,
Expand Down Expand Up @@ -948,7 +948,7 @@ public function removeState(array $options)
array('_id' => $options['devId'], 'users.device_user' => $options['user']),
array('$pull' => array('users' => array('device_user' => $options['user'])))
);
} catch (Exception $e) {
} catch (Horde_Mongo_Exception $e) {
$this->_logger->err(sprintf(
'[%s] %s',
$this->_procid,
Expand All @@ -969,7 +969,7 @@ public function removeState(array $options)
// Remove device data.
try {
$this->_db->HAS_device->remove(array('_id' => $options['devId']));
} catch (Exception $e) {
} catch (Horde_Mongo_Exception $e) {
$this->_logger->err(sprintf(
'[%s] %s',
$this->_procid,
Expand All @@ -993,7 +993,7 @@ public function removeState(array $options)
array('users.device_user'),
array('$pull' => array('users' => array('device_user' => $options['user'])))
);
} catch (Exception $e) {
} catch (Horde_Mongo_Exception $e) {
$this->_logger->err($e->getMessage());
throw new Horde_ActiveSync_Exception($e);
}
Expand All @@ -1014,7 +1014,7 @@ public function removeState(array $options)
$this->_db->HAS_map->remove($query);
$this->_db->HAS_mailmap->remove($query);
$this->_db->HAS_device->remove(array('users' => array('$size' => 0)));
} catch (Exception $e) {
} catch (Horde_Mongo_Exception $e) {
$this->_logger->err(sprintf(
'[%s] %s',
$this->_procid,
Expand Down Expand Up @@ -1048,7 +1048,7 @@ public function isDuplicatePIMAddition($id)
$query,
array('message_uid')
);
} catch (Exception $e) {
} catch (Horde_Mongo_Exception $e) {
$this->_logger->err(sprintf(
'[%s] %s',
$this->_procid,
Expand Down Expand Up @@ -1099,7 +1099,7 @@ public function getSyncCache($devid, $user, array $fields = null)
$query,
$projection
);
} catch (Exception $e) {
} catch (Horde_Mongo_Exception $e) {
$this->_logger->err(sprintf(
'[%s] %s',
$this->_procid,
Expand Down Expand Up @@ -1167,7 +1167,7 @@ public function saveSyncCache(array $cache, $devid, $user, array $dirty = array(
array('$set' => $update),
array('upsert' => true)
);
} catch (Exception $e) {
} catch (Horde_Mongo_Exception $e) {
$this->_logger->err(sprintf(
'[%s] %s',
$this->_procid,
Expand Down Expand Up @@ -1201,7 +1201,7 @@ public function deleteSyncCache($devid, $user = null)

try {
$this->_db->HAS_cache->remove($params);
} catch (Exception $e) {
} catch (Horde_Mongo_Exception $e) {
$this->_logger->err(sprintf(
'[%s] %s',
$this->_procid,
Expand Down Expand Up @@ -1251,7 +1251,7 @@ protected function _getPIMChangeTS(array $changes)
array('$group' => array('_id' => '$message_uid', 'max' => array('$max' => '$sync_modtime')))

);
} catch (Exception $e) {
} catch (Horde_Mongo_Exception $e) {
$this->_logger->err(sprintf(
'[%s] %s',
$this->_procid,
Expand Down Expand Up @@ -1300,7 +1300,7 @@ protected function _havePIMChanges()
);
try {
return (bool)$c->find($query, array('_id'))->count();
} catch (Exception $e) {
} catch (Horde_Mongo_Exception $e) {
$this->_logger->err(sprintf(
'[%s] %s',
$this->_procid,
Expand Down Expand Up @@ -1400,7 +1400,7 @@ function() {

try {
$this->_db->HAS_state->remove($query);
} catch (Exception $e) {
} catch (Horde_Mongo_Exception $e) {
$this->_logger->err(sprintf(
'[%s] %s',
$this->_procid,
Expand Down Expand Up @@ -1431,7 +1431,7 @@ function() {
);
try {
$c->remove($query);
} catch (Exception $e) {
} catch (Horde_Mongo_Exception $e) {
$this->_logger->err(sprintf(
'[%s] %s',
$this->_procid,
Expand Down

0 comments on commit eaa3990

Please sign in to comment.