mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-12-27 22:29:27 -05:00
Make postgres database error slightly more helpful
This commit is contained in:
parent
4932a7e2d9
commit
cd0864121b
@ -245,24 +245,27 @@ class SynapseHomeServer(HomeServer):
|
|||||||
db_conn.cursor(), database_engine, self.hostname
|
db_conn.cursor(), database_engine, self.hostname
|
||||||
)
|
)
|
||||||
if not all_users_native:
|
if not all_users_native:
|
||||||
sys.stderr.write(
|
quit_with_error(
|
||||||
"\n"
|
|
||||||
"******************************************************\n"
|
|
||||||
"Found users in database not native to %s!\n"
|
"Found users in database not native to %s!\n"
|
||||||
"You cannot changed a synapse server_name after it's been configured\n"
|
"You cannot changed a synapse server_name after it's been configured"
|
||||||
"******************************************************\n"
|
% (self.hostname,)
|
||||||
"\n" % (self.hostname,)
|
|
||||||
)
|
)
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
database_engine.check_database(db_conn.cursor())
|
database_engine.check_database(db_conn.cursor())
|
||||||
except IncorrectDatabaseSetup as e:
|
except IncorrectDatabaseSetup as e:
|
||||||
sys.stderr.write("*" * len(e.message) + '\n')
|
quit_with_error(e.message)
|
||||||
sys.stderr.write(e.message)
|
|
||||||
sys.stderr.write('\n')
|
|
||||||
sys.stderr.write("*" * len(e.message) + '\n')
|
def quit_with_error(error_string):
|
||||||
sys.exit(2)
|
message_lines = error_string.split("\n")
|
||||||
|
line_length = max([len(l) for l in message_lines]) + 2
|
||||||
|
sys.stderr.write("*" * line_length + '\n')
|
||||||
|
for line in message_lines:
|
||||||
|
if line.strip():
|
||||||
|
sys.stderr.write(" %s\n" % (line.strip(),))
|
||||||
|
sys.stderr.write("*" * line_length + '\n')
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
def get_version_string():
|
def get_version_string():
|
||||||
|
@ -28,7 +28,8 @@ class PostgresEngine(object):
|
|||||||
rows = txn.fetchall()
|
rows = txn.fetchall()
|
||||||
if rows and rows[0][0] != "UTF8":
|
if rows and rows[0][0] != "UTF8":
|
||||||
raise IncorrectDatabaseSetup(
|
raise IncorrectDatabaseSetup(
|
||||||
"Database has incorrect encoding: '%s' instead of 'UTF8'"
|
"Database has incorrect encoding: '%s' instead of 'UTF8'\n"
|
||||||
|
"See docs/postgres.rst for more information."
|
||||||
% (rows[0][0],)
|
% (rows[0][0],)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user