Exception: Saro::Dat::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/saro/dat/error.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code, detail = nil, cause: nil) ⇒ Error

Returns a new instance of Error.



76
77
78
79
80
81
# File 'lib/saro/dat/error.rb', line 76

def initialize(code, detail = nil, cause: nil)
  @code = code
  @detail = detail
  @explicit_cause = cause
  super(detail ? "#{code}: #{detail}" : code)
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



73
74
75
# File 'lib/saro/dat/error.rb', line 73

def code
  @code
end

#detailObject (readonly)

Returns the value of attribute detail.



74
75
76
# File 'lib/saro/dat/error.rb', line 74

def detail
  @detail
end

Class Method Details

.code_of(e) ⇒ Object



107
108
109
# File 'lib/saro/dat/error.rb', line 107

def code_of(e)
  e.is_a?(Error) ? e.code : nil
end

.wrap(code, detail, e) ⇒ Object



111
112
113
114
# File 'lib/saro/dat/error.rb', line 111

def wrap(code, detail, e)
  return e if e.is_a?(Error)
  new(code, detail, cause: e)
end

Instance Method Details

#causeObject



83
84
85
# File 'lib/saro/dat/error.rb', line 83

def cause
  @explicit_cause || super
end

#inspectObject



102
103
104
# File 'lib/saro/dat/error.rb', line 102

def inspect
  "#<Saro::Dat::Error #{@code}#{@detail ? " #{@detail.inspect}" : ''}>"
end

#retryObject



87
88
89
90
91
92
93
94
95
96
# File 'lib/saro/dat/error.rb', line 87

def retry
  if @code == ErrorCode::MANAGER_NO_ISSUABLE_CERTIFICATE
    c = cause
    return :transient if c.is_a?(Error) && c.code == ErrorCode::CERT_NOT_YET_ISSUABLE
    return :permanent
  end
  return :transient if ErrorCode::TRANSIENT.include?(@code)
  return :state if ErrorCode::STATE.include?(@code)
  :permanent
end

#security_event?Boolean

Returns:

  • (Boolean)


98
99
100
# File 'lib/saro/dat/error.rb', line 98

def security_event?
  ErrorCode::SECURITY.include?(@code)
end