Exception: Eco::API::Error
- Defined in:
- lib/eco/api/error.rb,
lib/eco/api/error/handler.rb,
lib/eco/api/error/handlers.rb
Overview
To identify api server errors
Direct Known Subclasses
CyclicSupervisor, EmailInvalid, EmailMissing, EmailTaken, ExternalIdTaken, InternalServerError, InvalidObjectId, SchemaNotFound, SupervisorNotFound, Unclassified, UnknownField, UnknownPersonId
Defined Under Namespace
Classes: CyclicSupervisor, EmailInvalid, EmailMissing, EmailTaken, ExternalIdTaken, Handler, Handlers, InternalServerError, InvalidObjectId, SchemaNotFound, SupervisorNotFound, Unclassified, UnknownErrorClass, UnknownField, UnknownPersonId
Instance Attribute Summary collapse
-
#entry ⇒ Object
readonly
Returns the value of attribute entry.
-
#err_msg ⇒ Object
readonly
Returns the value of attribute err_msg.
-
#msg ⇒ Object
readonly
Returns the value of attribute msg.
-
#session ⇒ Object
readonly
Returns the value of attribute session.
Class Method Summary collapse
- .descendants(direct: false) ⇒ Object
- .descendants?(direct: false) ⇒ Boolean
- .err_match?(err_msg) ⇒ Boolean
- .get_type(err_msg, first: true) ⇒ Object
- .known_err_class?(klass) ⇒ Boolean
- .validate_err_class(klass) ⇒ Object
Instance Method Summary collapse
- #built_error ⇒ Object
-
#initialize(msg = nil, err_msg:, session: nil, entry: nil) ⇒ Error
constructor
A new instance of Error.
Constructor Details
#initialize(msg = nil, err_msg:, session: nil, entry: nil) ⇒ Error
Returns a new instance of Error.
144 145 146 147 148 149 150 |
# File 'lib/eco/api/error.rb', line 144 def initialize(msg = nil, err_msg:, session: nil, entry: nil) @msg = msg @err_msg = err_msg @session = session @entry = entry super(built_error) end |
Instance Attribute Details
#entry ⇒ Object (readonly)
Returns the value of attribute entry.
142 143 144 |
# File 'lib/eco/api/error.rb', line 142 def entry @entry end |
#err_msg ⇒ Object (readonly)
Returns the value of attribute err_msg.
142 143 144 |
# File 'lib/eco/api/error.rb', line 142 def err_msg @err_msg end |
#msg ⇒ Object (readonly)
Returns the value of attribute msg.
142 143 144 |
# File 'lib/eco/api/error.rb', line 142 def msg @msg end |
#session ⇒ Object (readonly)
Returns the value of attribute session.
142 143 144 |
# File 'lib/eco/api/error.rb', line 142 def session @session end |
Class Method Details
.descendants(direct: false) ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/eco/api/error.rb', line 93 def descendants(direct: false) ObjectSpace.each_object(::Class).select do |klass| klass < self end.sort do |k_1, k_2| next -1 if k_2 < k_1 next 1 if k_1 < k_2 0 end.tap do |siblings| siblings.delete(Unclassified) if direct siblings.reject! do |si| siblings.any? {|s| si < s} end end end end |
.descendants?(direct: false) ⇒ Boolean
110 111 112 |
# File 'lib/eco/api/error.rb', line 110 def descendants?(direct: false) descendants(direct: direct).length.positive? end |
.err_match?(err_msg) ⇒ Boolean
114 115 116 |
# File 'lib/eco/api/error.rb', line 114 def err_match?(err_msg) err_msg =~ @match end |
.get_type(err_msg, first: true) ⇒ Object
118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/eco/api/error.rb', line 118 def get_type(err_msg, first: true) type = nil descendants(direct: true).reverse.each do |klass| next unless klass.err_match?(err_msg) type = klass next unless klass.descendants?(direct: true) type = klass.get_type(err_msg, first: false) || type end return type unless first type || Unclassified end |
.known_err_class?(klass) ⇒ Boolean
133 134 135 |
# File 'lib/eco/api/error.rb', line 133 def known_err_class?(klass) descendants.push(self).include?(klass) end |
.validate_err_class(klass) ⇒ Object
137 138 139 |
# File 'lib/eco/api/error.rb', line 137 def validate_err_class(klass) raise UnknownErrorClass.new(klass: klass) unless known_err_class?(klass) end |
Instance Method Details
#built_error ⇒ Object
152 153 154 |
# File 'lib/eco/api/error.rb', line 152 def built_error msg end |