Skip to content

Commit

Permalink
add more details in every error callback (php)
Browse files Browse the repository at this point in the history
  • Loading branch information
ColdeZhang committed Aug 18, 2024
1 parent 18f3eab commit 3afd4ba
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions BlueMapCommon/webapp/public/sql.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,7 @@ function send($data) {
$sql = new PDO("$driver:host=$hostname;port=$port;dbname=$database", $username, $password);
$sql->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e ) {
error_log($e->getMessage(), 0); // Logs the detailed error message
error(500, "Failed to connect to database");
error(500, "Failed to connect to database: ".$e->getMessage());
}

// provide map-tiles
Expand Down Expand Up @@ -202,7 +201,7 @@ function send($data) {
exit;
}

} catch (PDOException $e) { error(500, "Failed to fetch data"); }
} catch (PDOException $e) { error(500, "Failed to fetch data: ".$e->getMessage()); }

// no content if nothing found
http_response_code(204);
Expand Down Expand Up @@ -241,7 +240,7 @@ function send($data) {
send($line["data"]);
exit;
}
} catch (PDOException $e) { error(500, "Failed to fetch data"); }
} catch (PDOException $e) { error(500, "Failed to fetch data: ".$e->getMessage()); }
}

}
Expand Down

0 comments on commit 3afd4ba

Please sign in to comment.