Exception: Mongoid::Errors::MongoidError
- Inherits:
-
StandardError
- Object
- StandardError
- Mongoid::Errors::MongoidError
- Defined in:
- lib/mongoid/errors/mongoid_error.rb
Overview
Default parent Mongoid error for all custom errors. This handles the base key for the translations and provides the convenience method for translating the messages.
Direct Known Subclasses
AmbiguousRelationship, Callback, DeleteRestriction, DocumentNotFound, EagerLoad, InvalidCollection, InvalidConfigOption, InvalidDatabase, InvalidField, InvalidFind, InvalidIndex, InvalidOptions, InvalidScope, InvalidSetPolymorphicRelation, InvalidStorageOptions, InvalidTime, InverseNotFound, MixedRelations, NestedAttributesMetadataNotFound, NoDefaultSession, NoEnvironment, NoMapReduceOutput, NoParent, NoSessionConfig, NoSessionDatabase, NoSessionHosts, NoSessionsConfig, ReadonlyAttribute, ScopeOverwrite, TooManyNestedAttributeRecords, UnknownAttribute, UnsavedDocument, UnsupportedJavascript, UnsupportedVersion, Validations, VersioningNotOnRoot, MultiParameterAttributes::Errors::AttributeAssignmentError, MultiParameterAttributes::Errors::MultiparameterAssignmentErrors
Constant Summary
- BASE_KEY =
"mongoid.errors.messages"
Instance Method Summary (collapse)
-
- (String) compose_message(key, attributes)
Compose the message.
-
- (String) problem(key, attributes)
Create the problem.
-
- (String) resolution(key, attributes)
Create the resolution.
-
- (String) summary(key, attributes)
Create the summary.
-
- (String) translate(key, options)
Given the key of the specific error and the options hash, translate the message.
Instance Method Details
- (String) compose_message(key, attributes)
Compose the message.
20 21 22 23 24 |
# File 'lib/mongoid/errors/mongoid_error.rb', line 20 def (key, attributes) "\nProblem:\n #{problem(key, attributes)}"+ "\nSummary:\n #{summary(key, attributes)}"+ "\nResolution:\n #{resolution(key, attributes)}" end |
- (String) problem(key, attributes)
Create the problem.
48 49 50 |
# File 'lib/mongoid/errors/mongoid_error.rb', line 48 def problem(key, attributes) translate("#{key}.message", attributes) end |
- (String) resolution(key, attributes)
Create the resolution.
72 73 74 |
# File 'lib/mongoid/errors/mongoid_error.rb', line 72 def resolution(key, attributes) translate("#{key}.resolution", attributes) end |
- (String) summary(key, attributes)
Create the summary.
60 61 62 |
# File 'lib/mongoid/errors/mongoid_error.rb', line 60 def summary(key, attributes) translate("#{key}.summary", attributes) end |
- (String) translate(key, options)
Given the key of the specific error and the options hash, translate the message.
36 37 38 |
# File 'lib/mongoid/errors/mongoid_error.rb', line 36 def translate(key, ) ::I18n.translate("#{BASE_KEY}.#{key}", { locale: :en }.merge()) end |