]> git.openstreetmap.org Git - nominatim.git/commitdiff
fix return code for PHP exceptions
authorSarah Hoffmann <lonvia@denofr.de>
Wed, 16 Mar 2022 20:44:02 +0000 (21:44 +0100)
committerSarah Hoffmann <lonvia@denofr.de>
Wed, 16 Mar 2022 20:44:02 +0000 (21:44 +0100)
These have returned a 0 until now.

lib-php/init-website.php

index 770c245d4be3648db262b171e7d385e1b023d416..60367503a9bd787aa236d540163f21f6a311d58e 100644 (file)
@@ -26,7 +26,7 @@ function userError($sMsg)
 
 function exception_handler_json($exception)
 {
-    http_response_code($exception->getCode());
+    http_response_code($exception->getCode() == 0 ? 500 : $exception->getCode());
     header('Content-type: application/json; charset=utf-8');
     include(CONST_LibDir.'/template/error-json.php');
     exit();
@@ -34,7 +34,7 @@ function exception_handler_json($exception)
 
 function exception_handler_xml($exception)
 {
-    http_response_code($exception->getCode());
+    http_response_code($exception->getCode() == 0 ? 500 : $exception->getCode());
     header('Content-type: text/xml; charset=utf-8');
     echo '<?xml version="1.0" encoding="UTF-8" ?>'."\n";
     include(CONST_LibDir.'/template/error-xml.php');