Skip to content

Commit

Permalink
improve test bootstrap, don't catch every exception in service::reque…
Browse files Browse the repository at this point in the history
…st (#125)

Signed-off-by: Julien Veyssier <[email protected]>
  • Loading branch information
julien-nc authored Sep 21, 2024
1 parent 4e08920 commit e0a7b4d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
2 changes: 0 additions & 2 deletions lib/Controller/OpenAiAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

use Exception;
use OCA\OpenAi\Service\OpenAiAPIService;
use OCA\OpenAi\Service\OpenAiSettingsService;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
Expand All @@ -25,7 +24,6 @@ public function __construct(
string $appName,
IRequest $request,
private OpenAiAPIService $openAiAPIService,
private OpenAiSettingsService $openAiSettingsService,
private ?string $userId,
) {
parent::__construct($appName, $request);
Expand Down
4 changes: 0 additions & 4 deletions lib/Service/OpenAiAPIService.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
use OCP\Lock\LockedException;
use Psr\Log\LoggerInterface;
use RuntimeException;
use Throwable;

/**
* Service to make requests to OpenAI/LocalAI REST API
Expand Down Expand Up @@ -740,9 +739,6 @@ public function request(?string $userId, string $endPoint, array $params = [], s
} else {
throw new Exception($this->l10n->t('API request error: ') . $e->getMessage(), intval($e->getCode()));
}
} catch (Exception|Throwable $e) {
$this->logger->warning('API request error : ' . $e->getMessage(), ['exception' => $e]);
throw new Exception($this->l10n->t('Unknown API request error.'), Http::STATUS_INTERNAL_SERVER_ERROR);
}
}
}
5 changes: 4 additions & 1 deletion tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php

use OCP\App\IAppManager;
use OCP\Server;

require_once __DIR__ . '/../../../tests/bootstrap.php';

\OC_App::loadApps();
Server::get(IAppManager::class)->loadApps();
OC_Hook::clear();

0 comments on commit e0a7b4d

Please sign in to comment.