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

#backtrace_locationsObject

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.

SyntheticExceptions don’t have real backtrace_locations (Ruby Thread::Backtrace::Location objects). LogError calls this for backtrace_signature calculation — returning nil is safe.



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

def backtrace_locations
  nil
end

#causeObject

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.

SyntheticExceptions don’t have a cause chain. LogError calls this for CauseChainExtractor — returning nil skips extraction.



147
148
149
# File 'lib/rails_error_dashboard/manual_error_reporter.rb', line 147

def cause
  nil
end

#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



153
154
155
156
157
# File 'lib/rails_error_dashboard/manual_error_reporter.rb', line 153

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)


187
188
189
# File 'lib/rails_error_dashboard/manual_error_reporter.rb', line 187

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)


178
179
180
181
182
183
# File 'lib/rails_error_dashboard/manual_error_reporter.rb', line 178

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