fix(public.php): Actually pass specified HTTP code for exceptions

Signed-off-by: Josh <josh.t.richards@gmail.com>
pull/56170/head
Josh 2025-11-03 12:46:35 +07:00 committed by GitHub
parent 68e492ef17
commit da1083b5c5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 2 deletions

@ -89,10 +89,14 @@ try {
$baseuri = OC::$WEBROOT . '/public.php/' . $service . '/'; $baseuri = OC::$WEBROOT . '/public.php/' . $service . '/';
require_once $file; require_once $file;
} catch (Exception $ex) { } catch (Exception $ex) {
$status = 500; if ($ex instanceof ServiceUnavailableException && $ex->getCode === 0) {
if ($ex instanceof ServiceUnavailableException) {
$status = 503; $status = 503;
} }
if ($ex->getCode() > 0) {
$status = $ex->getCode();
} else {
$status = 500;
}
//show the user a detailed error page //show the user a detailed error page
Server::get(LoggerInterface::class)->error($ex->getMessage(), ['app' => 'public', 'exception' => $ex]); Server::get(LoggerInterface::class)->error($ex->getMessage(), ['app' => 'public', 'exception' => $ex]);
Server::get(ITemplateManager::class)->printExceptionErrorPage($ex, $status); Server::get(ITemplateManager::class)->printExceptionErrorPage($ex, $status);