class TaxCloud::Errors::TaxCloudError
Default parent TaxCloud
error for all custom errors. This handles the base key for the translations and provides the convenience method for translating the messages.
Generously borrowed from Mongoid.
Attributes
problem[R]
Problem occurred.
resolution[R]
Suggested problem resolution.
summary[R]
Summary of the problem.
Public Instance Methods
compose_message(key, attributes = {})
click to toggle source
Compose the message.
Parameters¶ ↑
- key
-
Lookup key in the translation table.
- attributes
-
The objects to pass to create the message.
# File lib/tax_cloud/errors/tax_cloud_error.rb, line 24 def compose_message(key, attributes = {}) @problem = create_problem(key, attributes) @summary = create_summary(key, attributes) @resolution = create_resolution(key, attributes) "\nProblem:\n #{@problem}" \ "\nSummary:\n #{@summary}" \ "\nResolution:\n #{@resolution}" end
Private Instance Methods
create_problem(key, attributes)
click to toggle source
create_resolution(key, attributes)
click to toggle source
create_summary(key, attributes)
click to toggle source
translate(key, options)
click to toggle source
Given the key of the specific error and the options hash, translate the message.
Parameters¶ ↑
- key
-
The key of the error in the locales.
- options
-
The objects to pass to create the message.
Returns a localized error message string.
# File lib/tax_cloud/errors/tax_cloud_error.rb, line 46 def translate(key, options) ::I18n.translate("#{BASE_KEY}.#{key}", { locale: :en }.merge(options)).strip end