Exception: MelissaData::Errors::MelissaDataError
- Inherits:
-
StandardError
- Object
- StandardError
- MelissaData::Errors::MelissaDataError
- Defined in:
- lib/melissadata/errors.rb
Overview
Main superclass of any errors in MelissaData. This provides some convenience methods for setting the error key. The error key is used as a default message from I18n.
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
-
#error_key ⇒ Object
The key for the error message.
-
#error_namespace ⇒ Object
The default error namespace which is used for the error key.
-
#initialize(message = nil, *args) ⇒ MelissaDataError
constructor
A new instance of MelissaDataError.
Constructor Details
#initialize(message = nil, *args) ⇒ MelissaDataError
Returns a new instance of MelissaDataError.
53 54 55 56 57 58 59 |
# File 'lib/melissadata/errors.rb', line 53 def initialize(=nil, *args) = { :_key => } if && !.is_a?(Hash) = { :_key => error_key, :_namespace => error_namespace }.merge( || {}) = translate_error() super end |
Class Method Details
.error_key(key = nil, namespace = nil) ⇒ Object
44 45 46 47 |
# File 'lib/melissadata/errors.rb', line 44 def self.error_key(key=nil, namespace=nil) define_method(:error_key) { key } error_namespace(namespace) if namespace end |
.error_namespace(namespace) ⇒ Object
49 50 51 |
# File 'lib/melissadata/errors.rb', line 49 def self.error_namespace(namespace) define_method(:error_namespace) { namespace } end |
Instance Method Details
#error_key ⇒ Object
The key for the error message. This should be set using the error_key method but can be overridden here if needed.
68 |
# File 'lib/melissadata/errors.rb', line 68 def error_key; nil; end |
#error_namespace ⇒ Object
The default error namespace which is used for the error key. This can be overridden here or by calling the “error_namespace” class method.
64 |
# File 'lib/melissadata/errors.rb', line 64 def error_namespace; "melissadata.errors"; end |