Exception: CuvvaError

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ CuvvaError

Returns a new instance of CuvvaError.



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/cuvva_error.rb', line 7

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
end

Instance Attribute Details

#codeObject

Returns the value of attribute code.



2
3
4
# File 'lib/cuvva_error.rb', line 2

def code
  @code
end

#metaObject

Returns the value of attribute meta.



4
5
6
# File 'lib/cuvva_error.rb', line 4

def meta
  @meta
end

#reasonsObject

Returns the value of attribute reasons.



3
4
5
# File 'lib/cuvva_error.rb', line 3

def reasons
  @reasons
end

#stackObject (readonly)

Returns the value of attribute stack.



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

def stack
  @stack
end

Instance Method Details

#to_hashObject



21
22
23
24
25
26
27
# File 'lib/cuvva_error.rb', line 21

def to_hash
	{
		code: self.code,
		reasons: self.reasons ? self.reasons.to_hash : nil,
		meta: self.meta ? self.meta.to_hash : nil,
	}
end

#to_json(*args) ⇒ Object



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

def to_json(*args)
	to_hash.to_json(*args)
end