More robust error handling and cleanup

这个提交包含在:
Alessio Caiazza 2022-08-25 19:18:53 +02:00
父节点 27a8d235fd
当前提交 d8c8260097
找不到此签名对应的密钥

查看文件

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