Module: Elastictastic::ServerError
- Defined in:
- lib/elastictastic/server_error.rb
Defined Under Namespace
Classes: ServerError
Constant Summary collapse
- ERROR_PATTERN =
/^([A-Z][A-Za-z]*)(?::\s*)?(.*)$/
- NESTED_PATTERN =
/^.*nested:\s+(.*)$/
Class Method Summary collapse
Class Method Details
.[](server_message, status = nil) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/elastictastic/server_error.rb', line 17 def [](, status = nil) match = ERROR_PATTERN.match() if match if (nested_match = NESTED_PATTERN.match(match[2])) return self[nested_match[1], status] else clazz = Elastictastic::ServerError.const_get(match[1]) error = clazz.new(match[2]) error.status = status error end else Elastictastic::ServerError::ServerError.new() end end |
.const_missing(name) ⇒ Object
11 12 13 14 15 |
# File 'lib/elastictastic/server_error.rb', line 11 def const_missing(name) Class.new(::Elastictastic::ServerError::ServerError).tap do |error| const_set(name, error) end end |