6
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/et_fake_ccd/forced_error_handling.rb', line 6
def with_forced_error_handling(r, stage:)
request_id = r.['request_id']
RequestStoreService.store "#{stage}-#{request_id}" unless request_id.nil?
count = request_id.nil? ? 1 : RequestStoreService.count("#{stage}-#{request_id}")
specs = JSON.parse(r.['force_failures'] || '{}')
spec = specs.fetch("#{stage}_stage", [])
response_code = spec[count - 1].to_i
if response_code.zero?
yield
else
r.halt response_code
end
end
|