Exception: CuvvaError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/cuvva_error.rb

Constant Summary collapse

@@http_status_map =
{ }

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ CuvvaError

Returns a new instance of CuvvaError.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/cuvva_error.rb', line 12

def initialize(*args)
  code, reasons, meta = args

  if meta === nil && !reasons.is_a?(Array)
    meta = reasons
    reasons = nil
  end

  @code = code
  @reasons = reasons
  @meta = meta
  @stack = caller
  @http_status = CuvvaError.http_status_map.has_key?(code) ?
    CuvvaError.http_status_map[code] :
    500
end

Instance Attribute Details

#codeObject

Returns the value of attribute code.



6
7
8
# File 'lib/cuvva_error.rb', line 6

def code
  @code
end

#http_statusObject (readonly)

Returns the value of attribute http_status.



10
11
12
# File 'lib/cuvva_error.rb', line 10

def http_status
  @http_status
end

#metaObject

Returns the value of attribute meta.



8
9
10
# File 'lib/cuvva_error.rb', line 8

def meta
  @meta
end

#reasonsObject

Returns the value of attribute reasons.



7
8
9
# File 'lib/cuvva_error.rb', line 7

def reasons
  @reasons
end

#stackObject (readonly)

Returns the value of attribute stack.



9
10
11
# File 'lib/cuvva_error.rb', line 9

def stack
  @stack
end

Class Method Details

.http_status_mapObject



33
34
35
# File 'lib/cuvva_error.rb', line 33

def self.http_status_map
  @@http_status_map
end

Instance Method Details

#to_jsonObject



29
30
31
# File 'lib/cuvva_error.rb', line 29

def to_json
  JSON.generate(to_hash)
end