remove err details from err CB to logger, for avoid leaking private information

This commit is contained in:
zhangyuheng 2024-08-19 00:29:33 +08:00
parent 3afd4baf32
commit 1da2d8890b

View File

@ -150,7 +150,8 @@ if (startsWith($path, "/maps/")) {
$sql = new PDO("$driver:host=$hostname;port=$port;dbname=$database", $username, $password); $sql = new PDO("$driver:host=$hostname;port=$port;dbname=$database", $username, $password);
$sql->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $sql->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e ) { } catch (PDOException $e ) {
error(500, "Failed to connect to database: ".$e->getMessage()); error_log($e->getMessage(), 0); // Logs the detailed error message
error(500, "Failed to connect to database");
} }
// provide map-tiles // provide map-tiles
@ -201,7 +202,10 @@ if (startsWith($path, "/maps/")) {
exit; exit;
} }
} catch (PDOException $e) { error(500, "Failed to fetch data: ".$e->getMessage()); } } catch (PDOException $e) {
error_log($e->getMessage(), 0);
error(500, "Failed to fetch data");
}
// no content if nothing found // no content if nothing found
http_response_code(204); http_response_code(204);
@ -240,7 +244,10 @@ if (startsWith($path, "/maps/")) {
send($line["data"]); send($line["data"]);
exit; exit;
} }
} catch (PDOException $e) { error(500, "Failed to fetch data: ".$e->getMessage()); } } catch (PDOException $e) {
error_log($e->getMessage(), 0);
error(500, "Failed to fetch data");
}
} }
} }