Return 500 and the exception message (on debug) on OCS

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2021-10-22 11:26:18 +02:00
parent fb18f29148
commit c160668b07
No known key found for this signature in database
GPG Key ID: 7076EA9751AACDDA
1 changed files with 9 additions and 3 deletions

View File

@ -79,7 +79,13 @@ try {
OC_API::setContentType();
$format = \OC::$server->getRequest()->getParam('format', 'xml');
$txt = 'Invalid query, please check the syntax. API specifications are here:'
.' http://www.freedesktop.org/wiki/Specifications/open-collaboration-services.'."\n";
OC_API::respond(new \OC\OCS\Result(null, \OCP\AppFramework\OCSController::RESPOND_NOT_FOUND, $txt), $format);
$txt = 'Internal Server Error'."\n";
try {
if (\OC::$server->getSystemConfig()->getValue('debug', false)) {
$txt .= $e->getMessage();
}
} catch (\Throwable $e) {
// Just to be save
}
OC_API::respond(new \OC\OCS\Result(null, \OCP\AppFramework\OCSController::RESPOND_SERVER_ERROR, $txt), $format);
}