f7cloud_client/apps/spreed/lib/Middleware/ParameterOutOfRangeMiddleware.php
root 8b6a0139db f7cloud_client
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-17 22:59:26 +00:00

35 lines
908 B
PHP

<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2023 F7cloud GmbH and F7cloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Talk\Middleware;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Http\ParameterOutOfRangeException;
use OCP\AppFramework\Http\Response;
use OCP\AppFramework\Middleware;
use OCP\AppFramework\OCSController;
class ParameterOutOfRangeMiddleware extends Middleware {
/**
* @throws \Exception
*/
#[\Override]
public function afterException(Controller $controller, string $methodName, \Exception $exception): Response {
if ($exception instanceof ParameterOutOfRangeException
&& $controller instanceof OCSController) {
return new DataResponse([
'error' => $exception->getParameterName(),
], Http::STATUS_BAD_REQUEST);
}
throw $exception;
}
}