Skip to content

Commit fd8dc93

Browse files
committed
Show message when connection to the database is not possible (#5346)
2 parents f35f529 + 67f93e5 commit fd8dc93

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/invidious.cr

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,13 @@ alias IV = Invidious
6060
CONFIG = Config.load
6161
HMAC_KEY = CONFIG.hmac_key
6262

63-
PG_DB = DB.open CONFIG.database_url
63+
PG_DB = begin
64+
DB.open CONFIG.database_url
65+
rescue ex
66+
puts "Failed to connect to PostgreSQL database: #{ex.cause.try &.message}"
67+
puts "Check your 'config.yml' database settings or PostgreSQL settings."
68+
exit(1)
69+
end
6470
ARCHIVE_URL = URI.parse("https://archive.org")
6571
PUBSUB_URL = URI.parse("https://pubsubhubbub.appspot.com")
6672
REDDIT_URL = URI.parse("https://www.reddit.com")
@@ -221,8 +227,8 @@ error 404 do |env|
221227
Invidious::Routes::ErrorRoutes.error_404(env)
222228
end
223229

224-
error 500 do |env, ex|
225-
error_template(500, ex)
230+
error 500 do |env, exception|
231+
error_template(500, exception)
226232
end
227233

228234
static_headers do |env|

0 commit comments

Comments
 (0)