mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 01:57:15 +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:
@ -390,7 +390,13 @@ class Admin::UsersController < Admin::AdminController
|
||||
ip = params[:ip]
|
||||
|
||||
# should we cache results in redis?
|
||||
location = Excon.get("https://ipinfo.io/#{ip}/json", read_timeout: 10, connect_timeout: 10).body rescue nil
|
||||
begin
|
||||
location = Excon.get(
|
||||
"https://ipinfo.io/#{ip}/json",
|
||||
read_timeout: 10, connect_timeout: 10
|
||||
)&.body
|
||||
rescue Excon::Error
|
||||
end
|
||||
|
||||
render json: location
|
||||
end
|
||||
@ -424,7 +430,7 @@ class Admin::UsersController < Admin::AdminController
|
||||
}
|
||||
|
||||
AdminUserIndexQuery.new(params).find_users(50).each do |user|
|
||||
user_destroyer.destroy(user, options) rescue nil
|
||||
user_destroyer.destroy(user, options)
|
||||
end
|
||||
|
||||
render json: success_json
|
||||
|
Reference in New Issue
Block a user