Exception handling added at many places

This commit is contained in:
Michael 2024-08-25 18:35:24 +00:00
parent e6daaf49ce
commit 518382036b
16 changed files with 174 additions and 44 deletions

View file

@ -220,7 +220,12 @@ class Search
$return = Contact::searchByName($search, $mode, true);
} else {
$p = $page > 1 ? 'p=' . $page : '';
$curlResult = DI::httpClient()->get(self::getGlobalDirectory() . '/search/people?' . $p . '&q=' . urlencode($search), HttpClientAccept::JSON, [HttpClientOptions::REQUEST => HttpClientRequest::CONTACTDISCOVER]);
try {
$curlResult = DI::httpClient()->get(self::getGlobalDirectory() . '/search/people?' . $p . '&q=' . urlencode($search), HttpClientAccept::JSON, [HttpClientOptions::REQUEST => HttpClientRequest::CONTACTDISCOVER]);
} catch (\Throwable $th) {
Logger::notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]);
return [];
}
if ($curlResult->isSuccess()) {
$searchResult = json_decode($curlResult->getBodyString(), true);
if (!empty($searchResult['profiles'])) {