mirror of
https://github.com/nextcloud/server.git
synced 2026-04-22 14:50:17 -04:00
Add better error handling
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
This commit is contained in:
parent
f778cbe7b9
commit
760db78dba
2 changed files with 9 additions and 3 deletions
|
|
@ -107,7 +107,7 @@ class IconController extends Controller {
|
|||
* @NoCSRFRequired
|
||||
*
|
||||
* @param $app string app name
|
||||
* @return FileDisplayResponse|DataDisplayResponse
|
||||
* @return FileDisplayResponse|DataDisplayResponse|NotFoundResponse
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getFavicon(string $app = 'core'): Response {
|
||||
|
|
@ -123,6 +123,9 @@ class IconController extends Controller {
|
|||
$iconFile = $this->imageManager->getCachedImage('favIcon-' . $app);
|
||||
} catch (NotFoundException $exception) {
|
||||
$icon = $this->iconBuilder->getFavicon($app);
|
||||
if ($icon === false || $icon === '') {
|
||||
return new NotFoundResponse();
|
||||
}
|
||||
$iconFile = $this->imageManager->setCachedImage('favIcon-' . $app, $icon);
|
||||
}
|
||||
$response = new FileDisplayResponse($iconFile, Http::STATUS_OK, ['Content-Type' => 'image/x-icon']);
|
||||
|
|
@ -142,7 +145,7 @@ class IconController extends Controller {
|
|||
* @NoCSRFRequired
|
||||
*
|
||||
* @param $app string app name
|
||||
* @return DataDisplayResponse|FileDisplayResponse
|
||||
* @return DataDisplayResponse|FileDisplayResponse|NotFoundResponse
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getTouchIcon(string $app = 'core'): Response {
|
||||
|
|
@ -157,6 +160,9 @@ class IconController extends Controller {
|
|||
$iconFile = $this->imageManager->getCachedImage('touchIcon-' . $app);
|
||||
} catch (NotFoundException $exception) {
|
||||
$icon = $this->iconBuilder->getTouchIcon($app);
|
||||
if ($icon === false || $icon === '') {
|
||||
return new NotFoundResponse();
|
||||
}
|
||||
$iconFile = $this->imageManager->setCachedImage('touchIcon-' . $app, $icon);
|
||||
}
|
||||
$response = new FileDisplayResponse($iconFile, Http::STATUS_OK, ['Content-Type' => 'image/png']);
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ class ThemingDefaults extends \OC_Defaults {
|
|||
}
|
||||
|
||||
/**
|
||||
* We pass a string and sanitizeHTML will return a string to in that case
|
||||
* We pass a string and sanitizeHTML will return a string too in that case
|
||||
* @psalm-suppress InvalidReturnStatement
|
||||
* @psalm-suppress InvalidReturnType
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in a new issue