Remove more uses of `rescue nil`.
This commit is contained in:
parent
77eb93ffb7
commit
0d74c30fa7
|
@ -73,7 +73,10 @@ class Search
|
|||
|
||||
return if day == 0 || month == 0 || day > 31 || month > 12
|
||||
|
||||
return Time.zone.parse("#{year}-#{month}-#{day}") rescue nil
|
||||
return begin
|
||||
Time.zone.parse("#{year}-#{month}-#{day}")
|
||||
rescue ArgumentError
|
||||
end
|
||||
end
|
||||
|
||||
if str.downcase == "yesterday"
|
||||
|
|
|
@ -66,7 +66,12 @@ after_initialize do
|
|||
|
||||
# ensure no race condition when poll is automatically closed
|
||||
if poll["close"].present?
|
||||
close_date = Time.zone.parse(poll["close"]) rescue nil
|
||||
close_date =
|
||||
begin
|
||||
close_date = Time.zone.parse(poll["close"])
|
||||
rescue ArgumentError
|
||||
end
|
||||
|
||||
raise StandardError.new I18n.t("poll.poll_must_be_open_to_vote") if close_date && close_date <= Time.zone.now
|
||||
end
|
||||
|
||||
|
@ -159,7 +164,12 @@ after_initialize do
|
|||
Jobs.cancel_scheduled_job(:close_poll, post_id: post.id, poll_name: name)
|
||||
|
||||
if poll["status"] == "open" && poll["close"].present?
|
||||
close_date = Time.zone.parse(poll["close"]) rescue nil
|
||||
close_date =
|
||||
begin
|
||||
Time.zone.parse(poll["close"])
|
||||
rescue ArgumentError
|
||||
end
|
||||
|
||||
Jobs.enqueue_at(close_date, :close_poll, post_id: post.id, poll_name: name) if close_date && close_date > Time.zone.now
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue