Skip to content

Commit

Permalink
add error handling: deal with link faiures
Browse files Browse the repository at this point in the history
The way we dealt with this before, is: we would rescue link errors,
print a message to the user and move forward with our script creating
other media.

I'm not sure if that will work while crating with nested attributes.
Even if I rescue it seems to fail adding the project_medias, though it
does create the project.

So for now, I'm printing an useful message and not showing the user
information if it errors.

But I'll look further into this.
  • Loading branch information
vasconsaurus committed Feb 12, 2024
1 parent cbd2f06 commit 489a0db
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ def get_medias_params
links = [
'https://meedan.com/post/addressing-misinformation-across-countries-a-pioneering-collaboration-between-taiwan-factcheck-center-vera-files',
'https://meedan.com/post/entre-becos-a-women-led-hyperlocal-newsletter-from-the-peripheries-of-brazil',

'https://meedan.com/post/check-global-launches-independent-media-response-fund-tackles-on-climate-misinformation',
'https://meedan.com/post/chambal-media',
'https://meedan.com/post/application-process-for-the-check-global-independent-media-response-fund',
Expand Down Expand Up @@ -316,9 +317,18 @@ def create_claim_title(media_params)
puts "Stretch your legs, this might take a while"
puts "On a mac took about 10 minutes to create all populated workspaces"

setup = Setup.new(answer.presence) # .presence : returns nil or the string
PopulatedProjects.new(setup).create_populated_projects

begin
setup = Setup.new(answer.presence) # .presence : returns nil or the string
PopulatedProjects.new(setup).create_populated_projects
rescue RuntimeError => e
if e.message.include?('We could not parse this link')
puts "—————"
puts "Couldn't create Links. \nMake sure Pender is running, or comment out Links so they are not created."
puts "—————"
else
raise e
end
end


# teams.each do |team|
Expand All @@ -330,6 +340,6 @@ def create_claim_title(media_params)
# create_confirmed_relationship(project_medias[8], project_medias[1])
# end

setup.get_users_emails_and_passwords.each { |user_info| puts user_info }
unless e then setup.get_users_emails_and_passwords.each { |user_info| puts user_info } end

Rails.cache.clear

0 comments on commit 489a0db

Please sign in to comment.