Class: RailsErrorDashboard::ManualErrorReporter::SyntheticException Private

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

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

SyntheticException: A fake exception object for manual error reporting

This class mimics a Ruby Exception to work with the existing LogError command, but represents errors from non-Ruby sources (frontend, mobile, etc.)

Defined Under Namespace

Classes: MockClass

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error_type:, message:, backtrace:) ⇒ SyntheticException

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of SyntheticException.

Parameters:

  • error_type (String)

    The error class name

  • message (String)

    The error message

  • backtrace (Array<String>)

    The stack trace



133
134
135
136
137
# File 'lib/rails_error_dashboard/manual_error_reporter.rb', line 133

def initialize(error_type:, message:, backtrace:)
  @error_type = error_type
  @message = message
  @backtrace = backtrace
end

Instance Attribute Details

#backtraceObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



128
129
130
# File 'lib/rails_error_dashboard/manual_error_reporter.rb', line 128

def backtrace
  @backtrace
end

#messageObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



128
129
130
# File 'lib/rails_error_dashboard/manual_error_reporter.rb', line 128

def message
  @message
end

Instance Method Details

#classObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a mock class object that represents the error type

Returns:

  • (Object)

    A class-like object with the error type as its name



141
142
143
144
145
# File 'lib/rails_error_dashboard/manual_error_reporter.rb', line 141

def class
  # Return a simple object that quacks like a class
  # This allows the error type to be stored correctly in the database
  @class ||= MockClass.new(@error_type)
end

#inspectString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Inspect for debugging

Returns:

  • (String)


175
176
177
# File 'lib/rails_error_dashboard/manual_error_reporter.rb', line 175

def inspect
  "#<#{@error_type}: #{@message}>"
end

#is_a?(klass) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Check if this is a specific error type

Parameters:

  • klass (Class, String)

    The class to check against

Returns:

  • (Boolean)


166
167
168
169
170
171
# File 'lib/rails_error_dashboard/manual_error_reporter.rb', line 166

def is_a?(klass)
  return true if klass == self.class
  return true if klass == SyntheticException
  return true if klass.to_s == @error_type
  false
end