class Softlayer::Errors::SoftlayerError

Attributes

problem[R]
resolution[R]
summary[R]

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/softlayer/errors/softlayer_error.rb, line 12
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 the problem.

Parameters

key

The error key.

attributes

The attributes to interpolate.

Returns the problem.

# File lib/softlayer/errors/softlayer_error.rb, line 45
def create_problem(key, attributes)
  translate("#{key}.message", attributes)
end
create_resolution(key, attributes) click to toggle source

Create the resolution.

Parameters

key

The error key.

attributes

The attributes to interpolate.

Returns the resolution.

# File lib/softlayer/errors/softlayer_error.rb, line 67
def create_resolution(key, attributes)
  translate("#{key}.resolution", attributes)
end
create_summary(key, attributes) click to toggle source

Create the summary.

Parameters

key

The error key.

attributes

The attributes to interpolate.

Returns the summary.

# File lib/softlayer/errors/softlayer_error.rb, line 56
def create_summary(key, attributes)
  translate("#{key}.summary", attributes)
end
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/softlayer/errors/softlayer_error.rb, line 34
def translate(key, options)
  ::I18n.translate("#{BASE_KEY}.#{key}", { locale: :en }.merge(options)).strip
end