Exception: LcpRuby::Error
- Inherits:
-
StandardError
- Object
- StandardError
- LcpRuby::Error
- Defined in:
- lib/lcp_ruby.rb
Direct Known Subclasses
BackgroundJobs::JobError, ConditionError, DataSource::ConnectionError, DataSource::ReadonlyError, DataSource::RecordNotFound, MenuRenderError, MetadataError, SchemaError, ServiceError, Workflow::WorkflowError
Instance Attribute Summary collapse
-
#i18n_interpolations ⇒ Object
readonly
Returns the value of attribute i18n_interpolations.
-
#i18n_key ⇒ Object
readonly
Returns the value of attribute i18n_key.
Instance Method Summary collapse
-
#initialize(message_or_key = nil, **interpolations) ⇒ Error
constructor
A new instance of Error.
- #localized_message ⇒ Object
Constructor Details
#initialize(message_or_key = nil, **interpolations) ⇒ Error
Returns a new instance of Error.
317 318 319 320 321 322 323 324 325 326 327 |
# File 'lib/lcp_ruby.rb', line 317 def initialize( = nil, **interpolations) if .is_a?(Symbol) || (.is_a?(String) && .start_with?("lcp_ruby.")) @i18n_key = .to_s @i18n_interpolations = interpolations # Backend bypasses enforce_available_locales; I18n.t(locale: :en) # would raise InvalidLocale when :en isn't in available_locales. super(I18n.backend.translate(:en, @i18n_key, default: @i18n_key, **interpolations)) else super() end end |
Instance Attribute Details
#i18n_interpolations ⇒ Object (readonly)
Returns the value of attribute i18n_interpolations.
315 316 317 |
# File 'lib/lcp_ruby.rb', line 315 def i18n_interpolations @i18n_interpolations end |
#i18n_key ⇒ Object (readonly)
Returns the value of attribute i18n_key.
315 316 317 |
# File 'lib/lcp_ruby.rb', line 315 def i18n_key @i18n_key end |
Instance Method Details
#localized_message ⇒ Object
329 330 331 332 |
# File 'lib/lcp_ruby.rb', line 329 def return unless @i18n_key I18n.t(@i18n_key, **(@i18n_interpolations || {}), default: ) end |