mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 17:41:17 +08:00
Remove use of rescue nil
.
* `rescue nil` is a really bad pattern to use in our code base. We should rescue errors that we expect the code to throw and not rescue everything because we're unsure of what errors the code would throw. This would reduce the amount of pain we face when debugging why something isn't working as expexted. I've been bitten countless of times by errors being swallowed as a result during debugging sessions.
This commit is contained in:
@ -128,7 +128,11 @@ module Discourse
|
||||
if Rails.env.development?
|
||||
plugin_hash = Digest::SHA1.hexdigest(all_plugins.map { |p| p.path }.sort.join('|'))
|
||||
hash_file = "#{Rails.root}/tmp/plugin-hash"
|
||||
old_hash = File.read(hash_file) rescue nil
|
||||
|
||||
old_hash = begin
|
||||
File.read(hash_file)
|
||||
rescue Errno::ENOENT
|
||||
end
|
||||
|
||||
if old_hash && old_hash != plugin_hash
|
||||
puts "WARNING: It looks like your discourse plugins have recently changed."
|
||||
@ -236,7 +240,13 @@ module Discourse
|
||||
end
|
||||
|
||||
def self.route_for(uri)
|
||||
uri = URI(uri) rescue nil unless uri.is_a?(URI)
|
||||
unless uri.is_a?(URI)
|
||||
uri = begin
|
||||
URI(uri)
|
||||
rescue URI::InvalidURIError
|
||||
end
|
||||
end
|
||||
|
||||
return unless uri
|
||||
|
||||
path = uri.path || ""
|
||||
|
Reference in New Issue
Block a user