Class: SSLErrorMgt
- Inherits:
-
Object
- Object
- SSLErrorMgt
- Defined in:
- lib/process/cloud/process/common.rb
Overview
Class to manage retry on errors before failing
Instance Method Summary collapse
- #error_detected(message, backtrace, e) ⇒ Object
-
#initialize(iMaxRetry = 5) ⇒ SSLErrorMgt
constructor
A new instance of SSLErrorMgt.
- #wait(message, issue = nil) ⇒ Object
Constructor Details
#initialize(iMaxRetry = 5) ⇒ SSLErrorMgt
Returns a new instance of SSLErrorMgt.
28 29 30 31 |
# File 'lib/process/cloud/process/common.rb', line 28 def initialize(iMaxRetry = 5) @retry = 0 @max_retry = iMaxRetry end |
Instance Method Details
#error_detected(message, backtrace, e) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/process/cloud/process/common.rb', line 49 def error_detected(, backtrace, e) if .match('SSLv2/v3 read server hello A: unknown protocol') return wait(, "'unknown protocol' SSL Error") elsif e.is_a?(Excon::Errors::InternalServerError) return wait(, ANSI.red(e.class)) else PrcLib.error("Exception %s: %s\n%s", e.class, , backtrace.join("\n")) return true end end |
#wait(message, issue = nil) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/process/cloud/process/common.rb', line 33 def wait(, issue = nil) if @retry < @max_retry sleep(2) @retry += 1 if PrcLib.level == 0 msg = format('%s/%s try... ', @retry, @max_retry) msg += issue unless issue.nil? print msg end return false else PrcLib.error('Too many retry. %s', ) return true end end |