diff --git a/ocs/v1.php b/ocs/v1.php
index 983bfd5f77da1118dcce4ddc61ad5f03cdd57fc8..0c24aa814ebbc95a259f57027cc5b1f989832d0b 100644
--- a/ocs/v1.php
+++ b/ocs/v1.php
@@ -67,9 +67,15 @@ try {
 	OC_API::setContentType();
 	http_response_code(405);
 	exit();
-} catch (Exception $ex) {
+} catch (\OC\OCS\Exception $ex) {
 	OC_API::respond($ex->getResult(), OC_API::requestedFormat());
 	exit();
+} catch (Throwable $ex) {
+	OC::$server->getLogger()->logException($ex);
+
+	OC_API::setContentType();
+	http_response_code(500);
+	exit();
 }
 
 /*