diff options
author | sfan5 <sfan5@live.de> | 2021-05-25 20:03:05 +0200 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2021-05-30 11:40:14 +0200 |
commit | a12017c564782b2645b3020a6b998b116789c7cc (patch) | |
tree | aff469cdf79d677929a220ad2bf0a8e5a9a9477f | |
parent | d7a4479eb382392555ece1638169aeea094acc31 (diff) | |
download | minetest-a12017c564782b2645b3020a6b998b116789c7cc.tar.gz minetest-a12017c564782b2645b3020a6b998b116789c7cc.tar.bz2 minetest-a12017c564782b2645b3020a6b998b116789c7cc.zip |
Provide exact error message if postgres connection string missing
-rw-r--r-- | src/database/database-postgresql.cpp | 27 | ||||
-rw-r--r-- | src/database/database-postgresql.h | 2 |
2 files changed, 17 insertions, 12 deletions
diff --git a/src/database/database-postgresql.cpp b/src/database/database-postgresql.cpp index e1bb39928..29ecd4223 100644 --- a/src/database/database-postgresql.cpp +++ b/src/database/database-postgresql.cpp @@ -39,20 +39,24 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "remoteplayer.h" #include "server/player_sao.h" -Database_PostgreSQL::Database_PostgreSQL(const std::string &connect_string) : +Database_PostgreSQL::Database_PostgreSQL(const std::string &connect_string, + const char *type) : m_connect_string(connect_string) { if (m_connect_string.empty()) { - throw SettingNotFoundException( - "Set pgsql_connection string in world.mt to " + // Use given type to reference the exact setting in the error message + std::string s = type; + std::string msg = + "Set pgsql" + s + "_connection string in world.mt to " "use the postgresql backend\n" "Notes:\n" - "pgsql_connection has the following form: \n" - "\tpgsql_connection = host=127.0.0.1 port=5432 user=mt_user " - "password=mt_password dbname=minetest_world\n" + "pgsql" + s + "_connection has the following form: \n" + "\tpgsql" + s + "_connection = host=127.0.0.1 port=5432 " + "user=mt_user password=mt_password dbname=minetest" + s + "\n" "mt_user should have CREATE TABLE, INSERT, SELECT, UPDATE and " - "DELETE rights on the database.\n" - "Don't create mt_user as a SUPERUSER!"); + "DELETE rights on the database. " + "Don't create mt_user as a SUPERUSER!"; + throw SettingNotFoundException(msg); } } @@ -166,7 +170,7 @@ void Database_PostgreSQL::rollback() } MapDatabasePostgreSQL::MapDatabasePostgreSQL(const std::string &connect_string): - Database_PostgreSQL(connect_string), + Database_PostgreSQL(connect_string, ""), MapDatabase() { connectToDatabase(); @@ -315,7 +319,7 @@ void MapDatabasePostgreSQL::listAllLoadableBlocks(std::vector<v3s16> &dst) * Player Database */ PlayerDatabasePostgreSQL::PlayerDatabasePostgreSQL(const std::string &connect_string): - Database_PostgreSQL(connect_string), + Database_PostgreSQL(connect_string, "_player"), PlayerDatabase() { connectToDatabase(); @@ -637,7 +641,8 @@ void PlayerDatabasePostgreSQL::listPlayers(std::vector<std::string> &res) } AuthDatabasePostgreSQL::AuthDatabasePostgreSQL(const std::string &connect_string) : - Database_PostgreSQL(connect_string), AuthDatabase() + Database_PostgreSQL(connect_string, "_auth"), + AuthDatabase() { connectToDatabase(); } diff --git a/src/database/database-postgresql.h b/src/database/database-postgresql.h index f47deda33..81b4a2b10 100644 --- a/src/database/database-postgresql.h +++ b/src/database/database-postgresql.h @@ -29,7 +29,7 @@ class Settings; class Database_PostgreSQL: public Database { public: - Database_PostgreSQL(const std::string &connect_string); + Database_PostgreSQL(const std::string &connect_string, const char *type); ~Database_PostgreSQL(); void beginSave(); |