Skip to content

Commit

Permalink
add logs the detailed error message in php (#595)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
ColdeZhang authored Aug 18, 2024
1 parent b422640 commit d5fe717
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions BlueMapCommon/webapp/public/sql.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,10 @@ function send($data) {
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/")) {
Expand Down Expand Up @@ -199,7 +202,10 @@ function send($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");
}

// no content if nothing found
http_response_code(204);
Expand Down Expand Up @@ -238,7 +244,10 @@ function send($data) {
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");
}
}

}
Expand Down

0 comments on commit d5fe717

Please sign in to comment.