Skip to content

Commit 67f93e5

Browse files
committed
Fix "ex" variable collision in invidious.cr
The exception handling for database connections results in an `ex` variable which Ameba sees as overshadowing the `ex` used by the `ex` block arg used to define the HTTP status code 500 handler below. Although this is a non-issue since the db connection exception handling will cause Invidious to exit, Ameba's nature as a static checker means that it isn't aware of this. The simplest fix without a dirty ameba ignore comment is to rename `ex` within the Kemal handler block below, since `ex` within a begin rescue block is a Crystal convention that will also cause Ameba to raise when not adhered to.
1 parent 8723fdc commit 67f93e5

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/invidious.cr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ HMAC_KEY = CONFIG.hmac_key
6262

6363
PG_DB = begin
6464
DB.open CONFIG.database_url
65-
rescue exc
66-
puts "Failed to connect to PostgreSQL database: #{exc.cause.try &.message}"
65+
rescue ex
66+
puts "Failed to connect to PostgreSQL database: #{ex.cause.try &.message}"
6767
puts "Check your 'config.yml' database settings or PostgreSQL settings."
6868
exit(1)
6969
end
@@ -227,8 +227,8 @@ error 404 do |env|
227227
Invidious::Routes::ErrorRoutes.error_404(env)
228228
end
229229

230-
error 500 do |env, ex|
231-
error_template(500, ex)
230+
error 500 do |env, exception|
231+
error_template(500, exception)
232232
end
233233

234234
static_headers do |env|

0 commit comments

Comments
 (0)