Merge pull request #11534 from nupplaphil/bug/catch_notfound
Catch exceptions for Worker::AddContact()
This commit is contained in:
commit
0b8e0a09e3
1 changed files with 19 additions and 9 deletions
|
@ -21,8 +21,10 @@
|
||||||
|
|
||||||
namespace Friendica\Worker;
|
namespace Friendica\Worker;
|
||||||
|
|
||||||
use Friendica\Core\Logger;
|
use Friendica\DI;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
|
use Friendica\Network\HTTPException\InternalServerErrorException;
|
||||||
|
use Friendica\Network\HTTPException\NotFoundException;
|
||||||
|
|
||||||
class AddContact
|
class AddContact
|
||||||
{
|
{
|
||||||
|
@ -33,14 +35,22 @@ class AddContact
|
||||||
*/
|
*/
|
||||||
public static function execute(int $uid, string $url)
|
public static function execute(int $uid, string $url)
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
if ($uid == 0) {
|
if ($uid == 0) {
|
||||||
// Adding public contact
|
// Adding public contact
|
||||||
$result = Contact::getIdForURL($url);
|
$result = Contact::getIdForURL($url);
|
||||||
Logger::info('Added public contact', ['url' => $url, 'result' => $result]);
|
DI::logger()->info('Added public contact', ['url' => $url, 'result' => $result]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = Contact::createFromProbeForUser($uid, $url);
|
$result = Contact::createFromProbeForUser($uid, $url);
|
||||||
Logger::info('Added contact for user', ['uid' => $uid, 'url' => $url, 'result' => $result]);
|
DI::logger()->info('Added contact for user', ['uid' => $uid, 'url' => $url, 'result' => $result]);
|
||||||
|
} catch (InternalServerErrorException $e) {
|
||||||
|
DI::logger()->warning('Internal server error.', ['exception' => $e, 'uid' => $uid, 'url' => $url]);
|
||||||
|
} catch (NotFoundException $e) {
|
||||||
|
DI::logger()->notice('uid not found.', ['exception' => $e, 'uid' => $uid, 'url' => $url]);
|
||||||
|
} catch (\ImagickException $e) {
|
||||||
|
DI::logger()->notice('Imagick not found.', ['exception' => $e, 'uid' => $uid, 'url' => $url]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue