Exception: Synthra::Errors::SimulatedError
- Inherits:
-
SimulatedBehaviorError
- Object
- StandardError
- Error
- SimulatedBehaviorError
- Synthra::Errors::SimulatedError
- Defined in:
- lib/synthra/errors.rb
Overview
Simulated HTTP error
Raised by the @simulate_error behavior to simulate specific HTTP error responses. Useful for testing how applications handle various HTTP status codes.
Constant Summary collapse
- ERROR_CODE =
"SIMULATED_ERROR"
Instance Attribute Summary collapse
-
#code ⇒ Integer
readonly
The HTTP status code being simulated.
-
#probability ⇒ Integer?
readonly
The configured probability percentage.
Instance Method Summary collapse
-
#initialize(code:, probability: nil) ⇒ SimulatedError
constructor
Create a new SimulatedError.
Constructor Details
#initialize(code:, probability: nil) ⇒ SimulatedError
Create a new SimulatedError
1099 1100 1101 1102 1103 1104 1105 |
# File 'lib/synthra/errors.rb', line 1099 def initialize(code:, probability: nil) @code = code @probability = probability = "Simulated HTTP error: #{code}" += " (#{probability}% probability)" if probability super() end |
Instance Attribute Details
#code ⇒ Integer (readonly)
Returns the HTTP status code being simulated.
1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 |
# File 'lib/synthra/errors.rb', line 1088 class SimulatedError < SimulatedBehaviorError ERROR_CODE = "SIMULATED_ERROR" attr_reader :code, :probability # Create a new SimulatedError # # @param code [Integer] the HTTP status code to simulate # @param probability [Integer, nil] the probability percentage if configured # def initialize(code:, probability: nil) @code = code @probability = probability = "Simulated HTTP error: #{code}" += " (#{probability}% probability)" if probability super() end end |
#probability ⇒ Integer? (readonly)
Returns the configured probability percentage.
1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 |
# File 'lib/synthra/errors.rb', line 1088 class SimulatedError < SimulatedBehaviorError ERROR_CODE = "SIMULATED_ERROR" attr_reader :code, :probability # Create a new SimulatedError # # @param code [Integer] the HTTP status code to simulate # @param probability [Integer, nil] the probability percentage if configured # def initialize(code:, probability: nil) @code = code @probability = probability = "Simulated HTTP error: #{code}" += " (#{probability}% probability)" if probability super() end end |