]> git.mxchange.org Git - friendica.git/commitdiff
Move jsonError out of Factory\Api\Mastodon\Error->InternalError
authorHypolite Petovan <hypolite@mrpetovan.com>
Wed, 11 Oct 2023 13:32:25 +0000 (09:32 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Wed, 11 Oct 2023 13:44:03 +0000 (09:44 -0400)
src/Factory/Api/Mastodon/Error.php
src/Module/Api/Mastodon/Apps.php
src/Module/Api/Mastodon/Lists.php
src/Module/Api/Mastodon/Statuses.php

index 7d8e026767d2e286ebdd16db3ca44a839de5bfa8..4f7159b7ec7c22c6885061a1e4033f70237fca13 100644 (file)
@@ -77,13 +77,10 @@ class Error extends BaseFactory
                return new \Friendica\Object\Api\Mastodon\Error($error, $error_description);
        }
 
-       public function InternalError(string $error = '')
+       public function InternalError(string $error = ''): \Friendica\Object\Api\Mastodon\Error
        {
                $error             = $error ?: $this->l10n->t('Internal Server Error');
                $error_description = '';
-               $errorObj          = new \Friendica\Object\Api\Mastodon\Error($error, $error_description);
-
-               $this->logError(500, $error);
-               $this->jsonError(500, $errorObj->toArray());
+               return new \Friendica\Object\Api\Mastodon\Error($error, $error_description);
        }
 }
index 9d6729216c563bb57e60d42adbe4e35a8b0ffade..5ebe3e2aba84efe0ebc7e7255b645ee2226ab18d 100644 (file)
@@ -92,7 +92,7 @@ class Apps extends BaseApi
                }
 
                if (!DBA::insert('application', $fields)) {
-                       DI::mstdnError()->InternalError();
+                       $this->logErrorAndJsonExit(500, $this->errorFactory->InternalError());
                }
 
                $this->jsonExit(DI::mstdnApplication()->createFromApplicationId(DBA::lastInsertId())->toArray());
index beb1a3b9a62455fd552f6a2022726c8d6eaa145d..3e66b9d51e6aadd39c36fe2d3cc0e244b7867921 100644 (file)
@@ -45,7 +45,7 @@ class Lists extends BaseApi
                }
 
                if (!Circle::remove($this->parameters['id'])) {
-                       DI::mstdnError()->InternalError();
+                       $this->logErrorAndJsonExit(500, $this->errorFactory->InternalError());
                }
 
                $this->jsonExit([]);
@@ -68,7 +68,7 @@ class Lists extends BaseApi
 
                $id = Circle::getIdByName($uid, $request['title']);
                if (!$id) {
-                       DI::mstdnError()->InternalError();
+                       $this->logErrorAndJsonExit(500, $this->errorFactory->InternalError());
                }
 
                $this->jsonExit(DI::mstdnList()->createFromCircleId($id));
index def4d51f631d03ab0324d0bf879b7e5d16b6f05b..5b6f8550aa54b181172d7d168bd4af375785d575 100644 (file)
@@ -297,7 +297,7 @@ class Statuses extends BaseApi
                        $item['uri'] = Item::newURI($item['guid']);
                        $id = Post\Delayed::add($item['uri'], $item, Worker::PRIORITY_HIGH, Post\Delayed::PREPARED, DateTimeFormat::utc($request['scheduled_at']));
                        if (empty($id)) {
-                               DI::mstdnError()->InternalError();
+                               $this->logErrorAndJsonExit(500, $this->errorFactory->InternalError());
                        }
                        $this->jsonExit(DI::mstdnScheduledStatus()->createFromDelayedPostId($id, $uid)->toArray());
                }
@@ -310,7 +310,7 @@ class Statuses extends BaseApi
                        }
                }
 
-               DI::mstdnError()->InternalError();
+               $this->logErrorAndJsonExit(500, $this->errorFactory->InternalError());
        }
 
        protected function delete(array $request = [])