Catch (timeout) errors on communication with hamqth

This commit is contained in:
phl0
2025-12-10 16:39:27 +01:00
parent 973b304a6d
commit 710b4ab726
2 changed files with 10 additions and 1 deletions

View File

@@ -125,7 +125,12 @@ class Callbook {
if (!$this->ci->session->userdata('hamqth_session_key')) {
$hamqth_session_key = $this->ci->hamqth->session($username, $password);
$this->ci->session->set_userdata('hamqth_session_key', $hamqth_session_key);
if ($hamqth_session_key == false) {
$callbook['error'] = __("Error obtaining a session key for HamQTH query");
return $callbook;
} else {
$this->ci->session->set_userdata('hamqth_session_key', $hamqth_session_key);
}
}
$callbook = $this->ci->hamqth->search($callsign, $this->ci->session->userdata('hamqth_session_key'));

View File

@@ -21,6 +21,10 @@ class Hamqth {
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$xml = curl_exec($ch);
curl_close($ch);
if(curl_errno($ch)) {
log_message('error', 'Hamqth query failed: '.curl_strerror(curl_errno($ch))." (".curl_errno($ch).")");
return false;
}
// Create XML object
$xml = simplexml_load_string($xml);