From 15eba2c9fced2a07934e2c2e31707713adf4d22f Mon Sep 17 00:00:00 2001 From: Jared Cosulich Date: Mon, 16 Oct 2017 08:53:06 -0400 Subject: [PATCH] more error handling --- lib/tasks/data.rake | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/tasks/data.rake b/lib/tasks/data.rake index 02f753fe..87d48648 100644 --- a/lib/tasks/data.rake +++ b/lib/tasks/data.rake @@ -218,7 +218,12 @@ namespace :data do key = key.gsub(/[[:space:]]/, ' ').strip.gsub(/\s+/, ' ') value = value.gsub(/[[:space:]]/, ' ').strip.downcase - question = Question.find_by_text(key) + begin + question = Question.find_by_text(key) + rescue Exception => e + puts "DATAERROR: Failed finding question: #{key} -> #{e}" + end + if question.nil? next if missing_questions[key] puts "DATAERROR: Unable to find question: #{key}" @@ -249,8 +254,8 @@ namespace :data do responded_at = Date.strptime(row['End Date'], '%m/%d/%Y %H:%M') begin recipient.attempts.create(question: question, answer_index: answer_index, responded_at: responded_at) - rescue - puts "DATAERROR: Attempt failed for #{recipient} -> QUESTION: #{question}, ANSWER_INDEX: #{answer_index}, RESPONDED_AT: #{responded_at}" + rescue Exception => e + puts "DATAERROR: Attempt failed for #{recipient} -> QUESTION: #{question}, ANSWER_INDEX: #{answer_index}, RESPONDED_AT: #{responded_at}, ERROR: #{e}" next end end