summary refs log tree commit diff
path: root/synapse/app/homeserver.py
diff options
context:
space:
mode:
Diffstat (limited to 'synapse/app/homeserver.py')
-rwxr-xr-xsynapse/app/homeserver.py27
1 files changed, 15 insertions, 12 deletions
diff --git a/synapse/app/homeserver.py b/synapse/app/homeserver.py
index cbd295c0a5..29a1bf1d70 100755
--- a/synapse/app/homeserver.py
+++ b/synapse/app/homeserver.py
@@ -245,24 +245,27 @@ class SynapseHomeServer(HomeServer):
             db_conn.cursor(), database_engine, self.hostname
         )
         if not all_users_native:
-            sys.stderr.write(
-                "\n"
-                "******************************************************\n"
+            quit_with_error(
                 "Found users in database not native to %s!\n"
-                "You cannot changed a synapse server_name after it's been configured\n"
-                "******************************************************\n"
-                "\n" % (self.hostname,)
+                "You cannot changed a synapse server_name after it's been configured"
+                % (self.hostname,)
             )
-            sys.exit(1)
 
         try:
             database_engine.check_database(db_conn.cursor())
         except IncorrectDatabaseSetup as e:
-            sys.stderr.write("*" * len(e.message) + '\n')
-            sys.stderr.write(e.message)
-            sys.stderr.write('\n')
-            sys.stderr.write("*" * len(e.message) + '\n')
-            sys.exit(2)
+            quit_with_error(e.message)
+
+
+def quit_with_error(error_string):
+    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():