Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add logs the detailed error message in php #595

Merged
merged 3 commits into from
Aug 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading