More robust error handling and cleanup

pull/1579/head
Alessio Caiazza 2022-08-25 19:18:53 +02:00
rodzic 27a8d235fd
commit d8c8260097
Nie znaleziono w bazie danych klucza dla tego podpisu
1 zmienionych plików z 36 dodań i 39 usunięć

Wyświetl plik

@ -53,9 +53,7 @@ class EqslImporter
// Download confirmed QSO from eQSL inbox and import them
public function fetch($password) {
if (empty($password) || empty($this->callsign)) {
$this->status = "Missing username and/or password";
return;
return $this->result('Missing username and/or password');
}
// Get URL for downloading the eqsl.cc inbox
@ -82,7 +80,7 @@ class EqslImporter
// Let's use cURL instead of file_get_contents
// begin script
$ch = curl_init();
try {
// basic curl options for all requests
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
@ -121,16 +119,15 @@ class EqslImporter
} else {
if ($chi['http_code'] == "500") {
return $this->result('eQSL.cc is experiencing issues. Please try importing QSOs later.'); // warning
} else {
if ($chi['http_code'] == "404") {
return $this->result('It seems that the eQSL site has changed. Please open up an issue on GitHub.');
}
}
}
return $this->result('It seems that the eQSL site has changed. Please open up an issue on GitHub.');
} finally {
// Close cURL handle
curl_close($ch);
}
}
// Read the ADIF file and set QSO confirmation status according to the settings
public function import(): array {