Skip to content

Commit 87656ae

Browse files
authored
text(Command/Sync): improve logging of 404 exceptions (#42)
1 parent 7314b25 commit 87656ae

1 file changed

Lines changed: 25 additions & 9 deletions

File tree

‎lib/Syncroton/Command/Sync.php‎

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -772,15 +772,24 @@ public function getResponse()
772772
->getEntry($fetchCollectionData, $serverId)
773773
->appendXML($applicationData, $this->_device);
774774

775-
$fetch->appendChild($this->_outputDom->createElementNS('uri:AirSync', 'Status', self::STATUS_SUCCESS));
775+
$fetch->appendChild($this->_outputDom->createElementNS('uri:AirSync',
776+
'Status', self::STATUS_SUCCESS));
776777

777778
$fetch->appendChild($applicationData);
779+
} catch (Syncroton_Exception_NotFound $senf) {
780+
if ($this->_logger instanceof Zend_Log) {
781+
$this->_logger->info(__METHOD__ . '::' . __LINE__
782+
. ' ' . $senf->getMessage());
783+
}
778784
} catch (Exception $e) {
779-
if ($this->_logger instanceof Zend_Log)
780-
$this->_logger->warn(__METHOD__ . '::' . __LINE__ . ' unable to convert entry ("' . $serverId . '") to xml: ' . $e->getMessage() . ' ' . get_class($e) . ' for data controller: ' . get_class($dataController));
781-
if ($this->_logger instanceof Zend_Log)
782-
$this->_logger->debug(__METHOD__ . '::' . __LINE__ . " unable to convert entry to xml: " . $e->getTraceAsString());
783-
$fetch->appendChild($this->_outputDom->createElementNS('uri:AirSync', 'Status', self::STATUS_OBJECT_NOT_FOUND));
785+
if ($this->_logger instanceof Zend_Log) {
786+
$this->_logger->warn(__METHOD__ . '::' . __LINE__
787+
. ' Unable to convert entry ("' . $serverId . '") to xml: ' . $e->getMessage()
788+
. ' ' . get_class($e) . ' for data controller: ' . get_class($dataController));
789+
$this->_logger->debug(__METHOD__ . '::' . __LINE__ . ' ' . $e->getTraceAsString());
790+
}
791+
$fetch->appendChild($this->_outputDom->createElementNS('uri:AirSync',
792+
'Status', self::STATUS_OBJECT_NOT_FOUND));
784793
}
785794
}
786795
}
@@ -836,12 +845,19 @@ public function getResponse()
836845
$this->_logger->warn(__METHOD__ . '::' . __LINE__ . " memory exhausted for entry: " . $serverId);
837846

838847
continue;
839-
848+
849+
} catch (Syncroton_Exception_NotFound $senf) {
850+
if ($this->_logger instanceof Zend_Log) {
851+
$this->_logger->info(__METHOD__ . '::' . __LINE__
852+
. ' ' . $senf->getMessage());
853+
}
840854
} catch (Exception $e) {
841855
if ($this->_logger instanceof Zend_Log)
842-
$this->_logger->warn(__METHOD__ . '::' . __LINE__ . " unable to convert entry to xml: " . $e->getMessage());
856+
$this->_logger->warn(__METHOD__ . '::' . __LINE__
857+
. " unable to convert entry to xml: " . $e->getMessage());
843858
if ($this->_logger instanceof Zend_Log)
844-
$this->_logger->debug(__METHOD__ . '::' . __LINE__ . " unable to convert entry to xml: " . $e->getTraceAsString());
859+
$this->_logger->debug(__METHOD__ . '::' . __LINE__
860+
. " " . $e->getTraceAsString());
845861
}
846862

847863
// mark as sent to the client, even the conversion to xml might have failed

0 commit comments

Comments
 (0)