Catch class Error on all root entrypoints
This commit is contained in:
parent
069af51dd0
commit
6a6fc742dc
|
@ -95,4 +95,6 @@ try {
|
||||||
$application->run();
|
$application->run();
|
||||||
} catch (Exception $ex) {
|
} catch (Exception $ex) {
|
||||||
exceptionHandler($ex);
|
exceptionHandler($ex);
|
||||||
|
} catch (Error $ex) {
|
||||||
|
exceptionHandler($ex);
|
||||||
}
|
}
|
||||||
|
|
2
cron.php
2
cron.php
|
@ -175,4 +175,6 @@ try {
|
||||||
|
|
||||||
} catch (Exception $ex) {
|
} catch (Exception $ex) {
|
||||||
\OCP\Util::writeLog('cron', $ex->getMessage(), \OCP\Util::FATAL);
|
\OCP\Util::writeLog('cron', $ex->getMessage(), \OCP\Util::FATAL);
|
||||||
|
} catch (Error $ex) {
|
||||||
|
\OCP\Util::writeLog('cron', $ex->getMessage(), \OCP\Util::FATAL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ try {
|
||||||
OC::handleRequest();
|
OC::handleRequest();
|
||||||
|
|
||||||
} catch(\OC\ServiceUnavailableException $ex) {
|
} catch(\OC\ServiceUnavailableException $ex) {
|
||||||
\OCP\Util::logException('index', $ex);
|
\OC::$server->getLogger()->logException($ex, ['app' => 'index']);
|
||||||
|
|
||||||
//show the user a detailed error page
|
//show the user a detailed error page
|
||||||
OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE);
|
OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE);
|
||||||
|
@ -48,9 +48,13 @@ try {
|
||||||
OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE);
|
OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE);
|
||||||
OC_Template::printErrorPage($ex->getMessage(), $ex->getHint());
|
OC_Template::printErrorPage($ex->getMessage(), $ex->getHint());
|
||||||
} catch (Exception $ex) {
|
} catch (Exception $ex) {
|
||||||
\OCP\Util::logException('index', $ex);
|
\OC::$server->getLogger()->logException($ex, ['app' => 'index']);
|
||||||
|
|
||||||
//show the user a detailed error page
|
//show the user a detailed error page
|
||||||
OC_Response::setStatus(OC_Response::STATUS_INTERNAL_SERVER_ERROR);
|
OC_Response::setStatus(OC_Response::STATUS_INTERNAL_SERVER_ERROR);
|
||||||
OC_Template::printExceptionErrorPage($ex);
|
OC_Template::printExceptionErrorPage($ex);
|
||||||
|
} catch (Error $ex) {
|
||||||
|
\OC::$server->getLogger()->logException($ex, ['app' => 'index']);
|
||||||
|
OC_Response::setStatus(OC_Response::STATUS_INTERNAL_SERVER_ERROR);
|
||||||
|
OC_Template::printExceptionErrorPage($ex);
|
||||||
}
|
}
|
||||||
|
|
|
@ -333,7 +333,7 @@ class OC_Template extends \OC\Template\Base {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* print error page using Exception details
|
* print error page using Exception details
|
||||||
* @param Exception $exception
|
* @param Exception | Throwable $exception
|
||||||
*/
|
*/
|
||||||
public static function printExceptionErrorPage($exception, $fetchPage = false) {
|
public static function printExceptionErrorPage($exception, $fetchPage = false) {
|
||||||
try {
|
try {
|
||||||
|
|
18
public.php
18
public.php
|
@ -49,7 +49,7 @@ try {
|
||||||
$pathInfo = trim($pathInfo, '/');
|
$pathInfo = trim($pathInfo, '/');
|
||||||
list($service) = explode('/', $pathInfo);
|
list($service) = explode('/', $pathInfo);
|
||||||
}
|
}
|
||||||
$file = OCP\CONFIG::getAppValue('core', 'public_' . strip_tags($service));
|
$file = OCP\Config::getAppValue('core', 'public_' . strip_tags($service));
|
||||||
if (is_null($file)) {
|
if (is_null($file)) {
|
||||||
header('HTTP/1.0 404 Not Found');
|
header('HTTP/1.0 404 Not Found');
|
||||||
exit;
|
exit;
|
||||||
|
@ -73,14 +73,18 @@ try {
|
||||||
|
|
||||||
require_once OC_App::getAppPath($app) . '/' . $parts[1];
|
require_once OC_App::getAppPath($app) . '/' . $parts[1];
|
||||||
|
|
||||||
} catch (\OC\ServiceUnavailableException $ex) {
|
|
||||||
//show the user a detailed error page
|
|
||||||
OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE);
|
|
||||||
\OCP\Util::writeLog('remote', $ex->getMessage(), \OCP\Util::FATAL);
|
|
||||||
OC_Template::printExceptionErrorPage($ex);
|
|
||||||
} catch (Exception $ex) {
|
} catch (Exception $ex) {
|
||||||
|
if ($ex instanceof \OC\ServiceUnavailableException) {
|
||||||
|
OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE);
|
||||||
|
} else {
|
||||||
|
OC_Response::setStatus(OC_Response::STATUS_INTERNAL_SERVER_ERROR);
|
||||||
|
}
|
||||||
|
//show the user a detailed error page
|
||||||
|
\OC::$server->getLogger()->logException($ex, ['app' => 'public']);
|
||||||
|
OC_Template::printExceptionErrorPage($ex);
|
||||||
|
} catch (Error $ex) {
|
||||||
//show the user a detailed error page
|
//show the user a detailed error page
|
||||||
OC_Response::setStatus(OC_Response::STATUS_INTERNAL_SERVER_ERROR);
|
OC_Response::setStatus(OC_Response::STATUS_INTERNAL_SERVER_ERROR);
|
||||||
\OCP\Util::writeLog('remote', $ex->getMessage(), \OCP\Util::FATAL);
|
\OC::$server->getLogger()->logException($ex, ['app' => 'public']);
|
||||||
OC_Template::printExceptionErrorPage($ex);
|
OC_Template::printExceptionErrorPage($ex);
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,9 +40,9 @@ class RemoteException extends Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Exception $e
|
* @param Exception | Error $e
|
||||||
*/
|
*/
|
||||||
function handleException(Exception $e) {
|
function handleException($e) {
|
||||||
$request = \OC::$server->getRequest();
|
$request = \OC::$server->getRequest();
|
||||||
// in case the request content type is text/xml - we assume it's a WebDAV request
|
// in case the request content type is text/xml - we assume it's a WebDAV request
|
||||||
$isXmlContentType = strpos($request->getHeader('Content-Type'), 'text/xml');
|
$isXmlContentType = strpos($request->getHeader('Content-Type'), 'text/xml');
|
||||||
|
@ -77,7 +77,7 @@ function handleException(Exception $e) {
|
||||||
OC_Response::setStatus($e->getCode());
|
OC_Response::setStatus($e->getCode());
|
||||||
OC_Template::printErrorPage($e->getMessage());
|
OC_Template::printErrorPage($e->getMessage());
|
||||||
} else {
|
} else {
|
||||||
\OCP\Util::writeLog('remote', $e->getMessage(), \OCP\Util::FATAL);
|
\OC::$server->getLogger()->logException($e, ['app' => 'remote']);
|
||||||
OC_Response::setStatus($statusCode);
|
OC_Response::setStatus($statusCode);
|
||||||
OC_Template::printExceptionErrorPage($e);
|
OC_Template::printExceptionErrorPage($e);
|
||||||
}
|
}
|
||||||
|
@ -165,4 +165,6 @@ try {
|
||||||
|
|
||||||
} catch (Exception $ex) {
|
} catch (Exception $ex) {
|
||||||
handleException($ex);
|
handleException($ex);
|
||||||
|
} catch (Error $e) {
|
||||||
|
handleException($ex);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue