Exception: LightServiceExt::ContextError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/light-service-ext/context_error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ctx:, error: nil, message: nil, fatal: false) ⇒ ContextError

Returns a new instance of ContextError.



13
14
15
16
17
18
19
# File 'lib/light-service-ext/context_error.rb', line 13

def initialize(ctx:, error: nil, message: nil, fatal: false)
  super
  @error = error
  @context = ctx
  message = message.presence || "Organizer completed with unhandled errors: \n#{formatted_validation_errors}"
  @error_info = ErrorInfo.new(error, message: message, fatal: fatal)
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



5
6
7
# File 'lib/light-service-ext/context_error.rb', line 5

def context
  @context
end

#errorObject (readonly)

Returns the value of attribute error.



5
6
7
# File 'lib/light-service-ext/context_error.rb', line 5

def error
  @error
end

#error_infoObject (readonly)

Returns the value of attribute error_info.



5
6
7
# File 'lib/light-service-ext/context_error.rb', line 5

def error_info
  @error_info
end

Instance Method Details

#messageObject



21
22
23
24
25
26
27
28
29
# File 'lib/light-service-ext/context_error.rb', line 21

def message
  error_message = <<~TEXT
    \nOrganizer: #{organizer_name}
      Action: #{action_name} failed with errors:
      Validation Errors: #{formatted_validation_errors}
  TEXT
  error_message = "#{error_message}\n#{error_info.error_summary}" if error
  error_message
end