From d5fe7175c661e3e9e679009199e29d3d758e5528 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=AE=87=E8=A1=A1?= Date: Mon, 19 Aug 2024 00:37:41 +0800 Subject: [PATCH] add logs the detailed error message in php (#595) * add logs the detailed error message in php * add more details in every error callback (php) * remove err details from err CB to logger, for avoid leaking private information --- BlueMapCommon/webapp/public/sql.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/BlueMapCommon/webapp/public/sql.php b/BlueMapCommon/webapp/public/sql.php index a9a43ffc..5cd1cbd8 100644 --- a/BlueMapCommon/webapp/public/sql.php +++ b/BlueMapCommon/webapp/public/sql.php @@ -149,7 +149,10 @@ if (startsWith($path, "/maps/")) { try { $sql = new PDO("$driver:host=$hostname;port=$port;dbname=$database", $username, $password); $sql->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - } catch (PDOException $e ) { error(500, "Failed to connect to database"); } + } catch (PDOException $e ) { + error_log($e->getMessage(), 0); // Logs the detailed error message + error(500, "Failed to connect to database"); + } // provide map-tiles if (startsWith($mapPath, "tiles/")) { @@ -199,7 +202,10 @@ if (startsWith($path, "/maps/")) { exit; } - } catch (PDOException $e) { error(500, "Failed to fetch data"); } + } catch (PDOException $e) { + error_log($e->getMessage(), 0); + error(500, "Failed to fetch data"); + } // no content if nothing found http_response_code(204); @@ -238,7 +244,10 @@ if (startsWith($path, "/maps/")) { send($line["data"]); exit; } - } catch (PDOException $e) { error(500, "Failed to fetch data"); } + } catch (PDOException $e) { + error_log($e->getMessage(), 0); + error(500, "Failed to fetch data"); + } } }