mirror of
https://git.sekbaer.de/Friendica/friendica.git
synced 2025-06-11 09:34:26 +02:00
Exception handling added at many places
This commit is contained in:
parent
e6daaf49ce
commit
518382036b
16 changed files with 174 additions and 44 deletions
|
@ -115,10 +115,16 @@ class Delivery
|
|||
$data = ActivityPub\Transmitter::createCachedActivityFromItem($item_id);
|
||||
if (!empty($data)) {
|
||||
$timestamp = microtime(true);
|
||||
$response = HTTPSignature::post($data, $inbox, $owner);
|
||||
$runtime = microtime(true) - $timestamp;
|
||||
$success = $response->isSuccess();
|
||||
$serverfail = $response->isTimeout();
|
||||
try {
|
||||
$response = HTTPSignature::post($data, $inbox, $owner);
|
||||
$success = $response->isSuccess();
|
||||
$serverfail = $response->isTimeout();
|
||||
} catch (\Throwable $th) {
|
||||
Logger::notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]);
|
||||
$success = false;
|
||||
$serverfail = true;
|
||||
}
|
||||
$runtime = microtime(true) - $timestamp;
|
||||
if (!$success) {
|
||||
// 5xx errors are problems on the server. We don't need to continue delivery then.
|
||||
if (!$serverfail && ($response->getReturnCode() >= 500) && ($response->getReturnCode() <= 599)) {
|
||||
|
|
|
@ -996,7 +996,12 @@ class DFRN
|
|||
|
||||
$content_type = ($public_batch ? 'application/magic-envelope+xml' : 'application/json');
|
||||
|
||||
$postResult = DI::httpClient()->post($dest_url, $envelope, ['Content-Type' => $content_type], 0, HttpClientRequest::DFRN);
|
||||
try {
|
||||
$postResult = DI::httpClient()->post($dest_url, $envelope, ['Content-Type' => $content_type], 0, HttpClientRequest::DFRN);
|
||||
} catch (\Throwable $th) {
|
||||
Logger::notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]);
|
||||
return -25;
|
||||
}
|
||||
Item::incrementOutbound(Protocol::DFRN);
|
||||
$xml = $postResult->getBodyString();
|
||||
|
||||
|
|
|
@ -2955,7 +2955,12 @@ class Diaspora
|
|||
if (!intval(DI::config()->get('system', 'diaspora_test'))) {
|
||||
$content_type = (($public_batch) ? 'application/magic-envelope+xml' : 'application/json');
|
||||
|
||||
$postResult = DI::httpClient()->post($dest_url . '/', $envelope, ['Content-Type' => $content_type], 0, HttpClientRequest::DIASPORA);
|
||||
try {
|
||||
$postResult = DI::httpClient()->post($dest_url . '/', $envelope, ['Content-Type' => $content_type], 0, HttpClientRequest::DIASPORA);
|
||||
} catch (\Throwable $th) {
|
||||
Logger::notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]);
|
||||
return 0;
|
||||
}
|
||||
$return_code = $postResult->getReturnCode();
|
||||
Item::incrementOutbound(Protocol::DIASPORA);
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue