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.

Constant Summary collapse

BASE_KEY =
"mongoid.errors.messages"

Instance Method Summary collapse

Instance Method Details

#compose_message(key, attributes) ⇒ String

Compose the message.

Examples:

Create the message

error.compose_message

Returns:

  • (String)

    The composed message.

Since:

  • 3.0.0



20
21
22
23
24
25
26
27
28
29
30
31
32
# 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)
  @problem_title = translate("message_title", {})
  @summary_title = translate("summary_title", {})
  @resolution_title = translate("resolution_title", {})


  "\n#{@problem_title}:\n  #{@problem}"+
  "\n#{@summary_title}:\n  #{@summary}"+
  "\n#{@resolution_title}:\n  #{@resolution}"
end