Exception: Mongoid::Errors::MongoidError

Inherits:
StandardError
  • Object
show all
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, DocumentNotDestroyed, DocumentNotFound, EagerLoad, InvalidCollection, InvalidConfigOption, InvalidField, InvalidFieldOption, InvalidFind, InvalidIncludes, InvalidIndex, InvalidOptions, InvalidPath, InvalidScope, InvalidSetPolymorphicRelation, InvalidStorageOptions, InvalidStorageParent, InvalidTime, InvalidValue, InverseNotFound, MixedRelations, MixedSessionConfiguration, NestedAttributesMetadataNotFound, NoDefaultSession, NoEnvironment, NoMapReduceOutput, NoMetadata, NoParent, NoSessionConfig, NoSessionDatabase, NoSessionHosts, NoSessionsConfig, ReadonlyAttribute, ReadonlyDocument, ScopeOverwrite, TooManyNestedAttributeRecords, UnknownAttribute, UnsavedDocument, UnsupportedJavascript, Validations

Constant Summary

BASE_KEY =
"mongoid.errors.messages"

Instance Method Summary (collapse)

Instance Method Details

- (String) compose_message(key, attributes)

Compose the message.

Examples:

Create the message

error.compose_message

Since:

  • 3.0.0



20
21
22
23
24
25
26
27
28
# File 'lib/mongoid/errors/mongoid_error.rb', line 20

def compose_message(key, attributes)
  @problem = problem(key, attributes)
  @summary = summary(key, attributes)
  @resolution = resolution(key, attributes)

  "\nProblem:\n  #{@problem}"+
  "\nSummary:\n  #{@summary}"+
  "\nResolution:\n  #{@resolution}"
end