Class: Contrast::Agent::Telemetry::Exception::MessageException
- Defined in:
- lib/contrast/agent/telemetry/exception/message_exception.rb
Overview
This class will hold the all the information for the specific exception and will be passed in the Exception message itself
Constant Summary collapse
- VALIDATIONS =
{ type: { required: true, range: 1..256 }, module_name: { required: false, range: 1..256 }, value: { required: false, range: 1..256 }, stack_frames: { required: true, range: 1..128, class: Contrast::Agent::Telemetry::Exception::StackFrame } }.cs__freeze
Instance Attribute Summary collapse
- #module_name ⇒ String
-
#stack_frames ⇒ Array<Contrast::Agent::Telemetry::Exception::StackFrame>
readonly
stack frames for the message exception.
-
#type ⇒ String
readonly
The type of the exception itself.
- #value ⇒ String
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(type, stack_frame) ⇒ MessageException
constructor
A new instance of MessageException.
-
#push(stack_frame) ⇒ Object
@raise.
- #to_controlled_hash ⇒ Object
Constructor Details
#initialize(type, stack_frame) ⇒ MessageException
Returns a new instance of MessageException.
38 39 40 41 42 43 |
# File 'lib/contrast/agent/telemetry/exception/message_exception.rb', line 38 def initialize type, stack_frame super() @type = type @stack_frames = Array.new(1, stack_frame) validate(VALIDATIONS) end |
Instance Attribute Details
#module_name ⇒ String
33 34 35 |
# File 'lib/contrast/agent/telemetry/exception/message_exception.rb', line 33 def module_name @module_name end |
#stack_frames ⇒ Array<Contrast::Agent::Telemetry::Exception::StackFrame> (readonly)
stack frames for the message exception
30 31 32 |
# File 'lib/contrast/agent/telemetry/exception/message_exception.rb', line 30 def stack_frames @stack_frames end |
#type ⇒ String (readonly)
Returns The type of the exception itself.
26 27 28 |
# File 'lib/contrast/agent/telemetry/exception/message_exception.rb', line 26 def type @type end |
#value ⇒ String
36 37 38 |
# File 'lib/contrast/agent/telemetry/exception/message_exception.rb', line 36 def value @value end |
Class Method Details
.build(type, value, module_name, stackframes) ⇒ Object
75 76 77 78 79 80 |
# File 'lib/contrast/agent/telemetry/exception/message_exception.rb', line 75 def build type, value, module_name, stackframes inst = new(type, stackframes) inst.module_name = module_name if module_name inst.value = value inst end |
Instance Method Details
#push(stack_frame) ⇒ Object
47 48 49 50 |
# File 'lib/contrast/agent/telemetry/exception/message_exception.rb', line 47 def push stack_frame validate_class(stack_frame, Contrast::Agent::Telemetry::Exception::StackFrame, 'stack_frame') @stack_frames << stack_frame end |
#to_controlled_hash ⇒ Object
64 65 66 67 68 69 70 71 72 |
# File 'lib/contrast/agent/telemetry/exception/message_exception.rb', line 64 def to_controlled_hash super { type: type, module: module_name, stackFrames: stack_frames.map(&:to_controlled_hash), value: value }.compact end |