Skip to content

Commit

Permalink
Add more details to Sentry error.
Browse files Browse the repository at this point in the history
Add exception class and message.

Reference: CV2-5552.
  • Loading branch information
caiosba committed Nov 8, 2024
1 parent 4eef8a6 commit d619967
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/models/relationship.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ def create_or_update_parent_id

def self.create_unless_exists(source_id, target_id, relationship_type, options = {})
r = Relationship.where(source_id: source_id, target_id: target_id).where('relationship_type = ?', relationship_type.to_yaml).last
exception_message = nil
exception_class = nil
if r.nil?
begin
r = Relationship.new
Expand All @@ -170,12 +172,14 @@ def self.create_unless_exists(source_id, target_id, relationship_type, options =
rescue StandardError => e
CheckSentry.notify(e, source_id: source_id, target_id: target_id, relationship_type: relationship_type)
r = Relationship.where(source_id: source_id, target_id: target_id).where('relationship_type = ?', relationship_type.to_yaml).last
exception_message = e.message
exception_class = e.class.name
end
end
if r.nil?
Rails.logger.error("[Relationship::create_unless_exists] returning nil: source_id #{source_id}, target_id #{target_id}, relationship_type #{relationship_type}.")
error_msg = StandardError.new('Unable to create new relationship as requested.')
CheckSentry.notify(error_msg, source_id: source_id, target_id: target_id, relationship_type: relationship_type, options: options)
CheckSentry.notify(error_msg, source_id: source_id, target_id: target_id, relationship_type: relationship_type, options: options, exception_message: exception_message, exception_class: exception_class)
end
r
end
Expand Down

0 comments on commit d619967

Please sign in to comment.