Added a bit better error handling. Writing errors to logfile now, if turned on in config.

pull/571/head
AndreasK79 2020-08-08 08:47:02 +02:00
rodzic ddfb3f5958
commit cea2cb3ea8
2 zmienionych plików z 15 dodań i 6 usunięć

Wyświetl plik

@ -36,7 +36,7 @@ class Qrz extends CI_Controller {
}
} else {
echo "No station_id's with a QRZ API Key found";
log_message('info', "No station_id's with a QRZ API Key found");
log_message('error', "No station_id's with a QRZ API Key found");
}
}
@ -67,9 +67,12 @@ class Qrz extends CI_Controller {
$result = $this->logbook_model->push_qso_to_qrz($qrz_api_key, $adif);
}
if ($result) {
if ($result['status'] == 'OK') {
$this->markqso($qso['COL_PRIMARY_KEY']);
$i++;
} else {
log_message('error', 'QRZ upload failed for qso: ' .$adif);
log_message('error', 'QRZ upload failed with the following message: ' .$result['message']);
}
}
return $i;

Wyświetl plik

@ -328,7 +328,8 @@ class Logbook_model extends CI_Model {
// Push qso to qrz if apikey is set
if ($apikey = $this->exists_qrz_api_key($data['station_id'])) {
$adif = $this->create_adif_from_data($data);
IF ($this->push_qso_to_qrz($apikey, $adif)) {
$result = $this->push_qso_to_qrz($apikey, $adif);
IF ($result['status'] == 'OK') {
$data['COL_QRZCOM_QSO_UPLOAD_STATUS'] = 'Y';
$data['COL_QRZCOM_QSO_UPLOAD_DATE'] = date("Y-m-d H:i:s", strtotime("now"));
}
@ -382,14 +383,19 @@ class Logbook_model extends CI_Model {
$content = curl_exec($ch);
if ($content){
if (stristr($content,'RESULT=OK') || stristr($content,'RESULT=REPLACE')) {
return true;
$result['status'] = 'OK';
return $result;
}
else {
return false;
$result['status'] = 'error';
$result['message'] = $content;
return $result;
}
}
if(curl_errno($ch)){
return false;
$result['status'] = 'error';
$result['message'] = 'Curl error: '. curl_errno($ch);
return $result;
}
curl_close($ch);
}