Skip to content

Commit

Permalink
Improve error logging
Browse files Browse the repository at this point in the history
  • Loading branch information
harigopal committed Oct 6, 2023
1 parent 354967f commit 7dada77
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions app/pupilfirst_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def initialize(submission = Submission.new)
end

def grade(result)
return puts 'Skipped grading' unless valid_status?(result['status'])
return puts "Unknown status: #{result['status'].inspect}. Skipping grading..." unless valid_status?(result['status'])

variables = {
submissionId: @submission.id,
Expand All @@ -42,11 +42,14 @@ def grade(result)
feedback: result['feedback']
}

puts "variables: #{variables}" if @test_mode
puts "[TEST MODE] Variables: #{variables.inspect}" if @test_mode

create_grading(variables) unless @test_mode
rescue StandardError => e
puts e
puts "An unexpected error occurred. Skipping grading..."
puts "Error class/type: #{e.class}"
puts "Error message: #{e.message}"
puts "Backtrace: #{e.backtrace[0..5].join("\n")}"
end

private
Expand All @@ -70,6 +73,7 @@ def grade_for(criteria, status)

def create_grading(variables)
result = API::Client.query(GradeMutation, variables: variables)

if result.data
puts result.data.create_grading.success
else
Expand Down

0 comments on commit 7dada77

Please sign in to comment.