kopia lustrzana https://github.com/iv-org/invidious
				
				
				
			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.pull/5346/head
							rodzic
							
								
									8723fdca06
								
							
						
					
					
						commit
						67f93e55d8
					
				| 
						 | 
				
			
			@ -62,8 +62,8 @@ HMAC_KEY = CONFIG.hmac_key
 | 
			
		|||
 | 
			
		||||
PG_DB = begin
 | 
			
		||||
  DB.open CONFIG.database_url
 | 
			
		||||
rescue exc
 | 
			
		||||
  puts "Failed to connect to PostgreSQL database: #{exc.cause.try &.message}"
 | 
			
		||||
rescue ex
 | 
			
		||||
  puts "Failed to connect to PostgreSQL database: #{ex.cause.try &.message}"
 | 
			
		||||
  puts "Check your 'config.yml' database settings or PostgreSQL settings."
 | 
			
		||||
  exit(1)
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			@ -227,8 +227,8 @@ error 404 do |env|
 | 
			
		|||
  Invidious::Routes::ErrorRoutes.error_404(env)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
error 500 do |env, ex|
 | 
			
		||||
  error_template(500, ex)
 | 
			
		||||
error 500 do |env, exception|
 | 
			
		||||
  error_template(500, exception)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
static_headers do |env|
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Ładowanie…
	
		Reference in New Issue