From a75751328004d431e33ee7565653391b157ef038 Mon Sep 17 00:00:00 2001 From: Josh Date: Mon, 3 Nov 2025 12:54:05 -0500 Subject: [PATCH] fix(remote.php): use status code in error handling Signed-off-by: Josh --- remote.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/remote.php b/remote.php index 2cfd9d818c8..3090bbee6a6 100644 --- a/remote.php +++ b/remote.php @@ -54,16 +54,20 @@ function handleException(Exception|Error $e): void { }); $server->exec(); } else { - $statusCode = 500; - if ($e instanceof ServiceUnavailableException) { - $statusCode = 503; - } if ($e instanceof RemoteException) { // we shall not log on RemoteException \OCP\Server::get(ITemplateManager::class)->printErrorPage($e->getMessage(), '', $e->getCode()); } else { + if ($ex instanceof ServiceUnavailableException && $e->getCode === 0) { + $status = 503; + } + if ($e->getCode() > 0) { + $status = $e->getCode(); + } else { + $status = 500; + } \OCP\Server::get(LoggerInterface::class)->error($e->getMessage(), ['app' => 'remote','exception' => $e]); - \OCP\Server::get(ITemplateManager::class)->printExceptionErrorPage($e, $statusCode); + \OCP\Server::get(ITemplateManager::class)->printExceptionErrorPage($e, $status); } } } catch (\Exception $e) {