# File lib/core/errors.rb, line 40 def self.error_key(key = nil, namespace = nil) define_method(:error_key) { key } error_namespace(namespace) if namespace end
# File lib/core/errors.rb, line 48 def self.error_message(message) define_method(:error_message) { message } end
# File lib/core/errors.rb, line 55 def self.error_namespace(namespace) define_method(:error_namespace) { namespace } end
# File lib/core/errors.rb, line 13 def initialize(*args) key = args.shift if args.first.is_a?(Symbol) message = args.shift if args.first.is_a?(Hash) message ||= {} @extra_data = message.dup message[:key] ||= error_key message[:namespace] ||= error_namespace message[:key] = key if key if message[:key] message = translate_error(message) else message = error_message end super(message) end
# File lib/core/errors.rb, line 62 def self.status_code(code) define_method(:status_code) { code } end
# File lib/core/errors.rb, line 44 def error_key; nil; end
# File lib/core/errors.rb, line 51 def error_message; "No error message"; end
# File lib/core/errors.rb, line 58 def error_namespace; "nucleon.errors"; end
# File lib/core/errors.rb, line 65 def status_code; 1; end
# File lib/core/errors.rb, line 70 def translate_error(options) return nil unless options[:key] I18n.t("#{options[:namespace]}.#{options[:key]}", options) end