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
This commit is contained in:
张宇衡 2024-08-19 00:37:41 +08:00 committed by GitHub
parent b422640a76
commit d5fe7175c6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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");
}
}
}