Class: Lev::Handler::Error

Inherits:
Object
  • Object
show all
Defined in:
lib/lev/handler/error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Error

Returns a new instance of Error.

Raises:

  • (IllegalArgument)


13
14
15
16
17
18
19
20
21
22
23
# File 'lib/lev/handler/error.rb', line 13

def initialize(args={})
  raise IllegalArgument if args[:code].blank?

  self.code = args[:code]
  self.data = args[:data]
  self.kind = args[:kind]
  self.message = args[:message]
  
  self.offending_params = args[:offending_params]
  self.offending_params = [self.offending_params] if !(self.offending_params.is_a? Array)
end

Instance Attribute Details

#codeObject

need a type or source that can be :activerecord when activerecord, data should contain specific fields that can be used by generate_message in BetterErrors



7
8
9
# File 'lib/lev/handler/error.rb', line 7

def code
  @code
end

#dataObject

Returns the value of attribute data.



8
9
10
# File 'lib/lev/handler/error.rb', line 8

def data
  @data
end

#kindObject

Returns the value of attribute kind.



9
10
11
# File 'lib/lev/handler/error.rb', line 9

def kind
  @kind
end

#messageObject

Returns the value of attribute message.



10
11
12
# File 'lib/lev/handler/error.rb', line 10

def message
  @message
end

#offending_paramsObject

Returns the value of attribute offending_params.



11
12
13
# File 'lib/lev/handler/error.rb', line 11

def offending_params
  @offending_params
end

Instance Method Details

#translateObject



25
26
27
# File 'lib/lev/handler/error.rb', line 25

def translate
  ErrorTranslator.translate(self)
end