Class: RailsErrorDashboard::Commands::ResolveError

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_error_dashboard/commands/resolve_error.rb

Overview

Command: Mark an error as resolved This is a write operation that updates an ErrorLog record

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error_id, resolution_data = {}) ⇒ ResolveError

Returns a new instance of ResolveError.



12
13
14
15
# File 'lib/rails_error_dashboard/commands/resolve_error.rb', line 12

def initialize(error_id, resolution_data = {})
  @error_id = error_id
  @resolution_data = resolution_data
end

Class Method Details

.call(error_id, resolution_data = {}) ⇒ Object



8
9
10
# File 'lib/rails_error_dashboard/commands/resolve_error.rb', line 8

def self.call(error_id, resolution_data = {})
  new(error_id, resolution_data).call
end

Instance Method Details

#callObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/rails_error_dashboard/commands/resolve_error.rb', line 17

def call
  error = ErrorLog.find(@error_id)

  error.update!(
    resolved: true,
    resolved_at: Time.current,
    resolved_by_name: @resolution_data[:resolved_by_name],
    resolution_comment: @resolution_data[:resolution_comment],
    resolution_reference: @resolution_data[:resolution_reference]
  )

  # Dispatch plugin event for resolved error
  PluginRegistry.dispatch(:on_error_resolved, error)

  # Trigger notification callbacks
  RailsErrorDashboard.configuration.notification_callbacks[:error_resolved].each do |callback|
    callback.call(error)
  rescue => e
    RailsErrorDashboard::Logger.error("Error in error_resolved callback: #{e.message}")
  end

  # Emit ActiveSupport::Notifications instrumentation event
  ActiveSupport::Notifications.instrument("error_resolved.rails_error_dashboard", {
    error_log: error,
    error_id: error.id,
    error_type: error.error_type,
    resolved_by: @resolution_data[:resolved_by_name],
    resolved_at: error.resolved_at
  })

  error
end