异常:Mongoid::Errors::MongoidError

继承:
StandardError
  • 对象
显示全部
定义于:
lib/mongoid/errors/mongoid_error.rb

Overview

所有自定义错误的默认父 Mongoid 错误。 这会处理转换的基本密钥,并提供转换消息的便捷方法。

直接已知子类

AmbiguousRelationship , AttributeNotLoaded , Callback , CreateCollectionFailure , CriteriaArgumentRequired , DeleteRestriction , DocumentNotDestroyed , DocumentNotFound , DropCollectionFailure , EmptyConfigFile , ImmutableAttribute , InMemoryCollationNotSupported , InvalidAroundCallback , InvalidAutoEncryptionConfiguration , InvalidCollection , InvalidConfigFile , InvalidConfigOption , InvalidDependentStrategy , InvalidDiscriminatorKeyTarget , InvalidDotDollarAssignment , InvalidEstimatedCountCriteria , InvalidEstimatedCountScoping , InvalidField , InvalidFieldOption , InvalidFieldType , InvalidFind , InvalidGlobalExecutorConcurrency , InvalidIncludes , InvalidIndex , InvalidOptions , InvalidPath , InvalidPersistenceOption , InvalidQuery , InvalidQueryExecutor , InvalidRelation , InvalidRelationOption , InvalidScope , InvalidSessionNesting , InvalidSetPolymorphicRelation , InvalidStorageOptions , InvalidTime , InvalidTransactionNesting , InverseNotFound , MixedClientConfiguration , Mix edRelations , NestedAttributesMetadataNotFound , NoClientConfig , NoClientDatabase , NoClientHosts , NoClientsConfig , NoDefaultClient , NoEnvironment , NoMapReduceOutput , NoMetadata , NoParent , ReadonlyAttribute , ReadonlyDocument , Rollback , ScopeOverwrite , SessionsNotSupported , TooManyNestedAttributeRecords , TransactionError , TransactionsNotSupported , UnknownAttribute , UnknownModel , UnrecognizedModelAlias , UnrecognizedResolver , UnregisteredClass , UnsavedDocument , UnsupportedJavascript,验证

常量摘要折叠

BASE_KEY =
"mongoid.errors.messages"

实例属性摘要折叠

实例方法摘要折叠

实例属性详细信息

#问题对象(只读)

返回属性问题的值。



12
13
14
# File 'lib/mongoid/errors/mongoid_error.rb', line 12

def 问题
  @问题
end

# resolution对象(只读)

返回属性解析的值。



12
13
14
# File 'lib/mongoid/errors/mongoid_error.rb', line 12

def 解决方案
  @解析
end

#摘要对象(只读)

返回属性摘要的值。



12
13
14
# File 'lib/mongoid/errors/mongoid_error.rb', line 12

def 总结
  @summary
end

实例方法详细信息

# compose_message (key, properties = {}) ⇒ string

撰写消息。

例子:

创建消息

error.compose_message

返回:

  • ( string )

    撰写的消息。



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/mongoid/errors/mongoid_error.rb', line 22

def compose_message(key, 属性 = {})
  @问题 = translate_问题(key, 属性)
  @summary = translate_summary(key, 属性)
  @解析 = Translate_Resouce(key, 属性)
  @issue_title = 翻译(" message_title ", {})
  @summary_title = 翻译(" summary_title ", {})
  @ resolution_title = 翻译(" resolution_title ", {})


  " \n #{ @issue_title } :\n #{ @problem &.strip } "+
  " \n #{ @summary_title } :\n #{ @summary &.strip } "+
  " \n #{ @processing_title } :\n #{ @processing &.strip } "
end