class Halt::Error

Error object to house the translation logic and exception/status information passed in when halt has been called or an exception is being rescued.

@api private

Constants

DESCRIPTIONS
MESSAGES

Attributes

description[W]
exception[RW]
message[W]
status[RW]

Public Class Methods

new(status, exception: nil, message: nil, description: nil) click to toggle source

@param [Symbol] status @keyword [Exception] exception @keyword [String] message @keyword [String] description

# File lib/halt/error.rb, line 24
def initialize(status, exception: nil, message: nil, description: nil)
  @status = status
  @exception = exception
  @message = message
  @description = description
end

Public Instance Methods

attributes() click to toggle source

@return [Hash]

# File lib/halt/error.rb, line 42
def attributes
  {
    status: status,
    message: message,
    description: description
  }
end
description() click to toggle source

@return [String]

# File lib/halt/error.rb, line 37
def description
  @description ||= translate DESCRIPTIONS
end
message() click to toggle source

@return [String]

# File lib/halt/error.rb, line 32
def message
  @message ||= translate MESSAGES
end

Private Instance Methods

translate(scope) click to toggle source

@private @param [String] key

# File lib/halt/error.rb, line 54
def translate(scope)
  I18n.translate status, scope: scope
end