Class: Lev::ErrorTranslator

Inherits:
Object show all
Defined in:
lib/lev/error_translator.rb

Class Method Summary collapse

Class Method Details

.translate(error) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/lev/error_translator.rb', line 5

def self.translate(error)
  case error.kind
  when :activerecord
    attribute = error.data[:attribute]
    message = error.message
    model = error.data[:model]
    ActiveModel::Error.full_message(attribute, message, model)
  else
    message = error.message.to_s
    message.empty? ? error.code.to_s : message
  end
end