Exception: Synthra::Errors::SimulatedFailure
- Inherits:
-
SimulatedBehaviorError
- Object
- StandardError
- Error
- SimulatedBehaviorError
- Synthra::Errors::SimulatedFailure
- Defined in:
- lib/synthra/errors.rb
Overview
Simulated failure (service unavailable)
Raised by the @failure behavior to simulate a service being unavailable. Useful for testing retry logic and error handling.
Constant Summary collapse
- ERROR_CODE =
"SIMULATED_FAILURE"
Instance Attribute Summary collapse
-
#probability ⇒ Integer?
readonly
The configured failure probability percentage.
Instance Method Summary collapse
-
#initialize(probability: nil) ⇒ SimulatedFailure
constructor
Create a new SimulatedFailure.
Constructor Details
#initialize(probability: nil) ⇒ SimulatedFailure
Create a new SimulatedFailure
1027 1028 1029 1030 1031 1032 |
# File 'lib/synthra/errors.rb', line 1027 def initialize(probability: nil) @probability = probability = "Simulated failure" += " (#{probability}% probability)" if probability super() end |
Instance Attribute Details
#probability ⇒ Integer? (readonly)
Returns the configured failure probability percentage.
1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 |
# File 'lib/synthra/errors.rb', line 1017 class SimulatedFailure < SimulatedBehaviorError ERROR_CODE = "SIMULATED_FAILURE" attr_reader :probability # Create a new SimulatedFailure # # @param probability [Integer, nil] the probability percentage if configured # def initialize(probability: nil) @probability = probability = "Simulated failure" += " (#{probability}% probability)" if probability super() end end |