Exception: Spud::RequestError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/spud_core/errors.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(item_or_opts = 'page', opts = {}) ⇒ RequestError

For compatability reasons, this method accepts multiple styles of inputs Going forward the expected input will be:

  • item: The item that could not be found. String. (default = page)

  • template (named): ERB template you wish to render



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/spud_core/errors.rb', line 11

def initialize(item_or_opts='page', opts={})
  if item_or_opts.is_a?(Hash)
    # ActiveSupport::Deprecation.warn("Passing the :item as a key/value pair to #{self.class.to_s} is deprecated; Pass it as the first argument instead.")
    @item = item_or_opts[:item]
    @template = item_or_opts[:template]
  else
    @item = item_or_opts
    @template = opts[:template]
  end
  @template ||= 'layouts/error_page'
  @title = I18n.t(:title, :scope => [:tb_core, :errors, @i18n])
  super(I18n.t(:message, :scope => [:tb_core, :errors, @i18n], :item => @item))
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



3
4
5
# File 'lib/spud_core/errors.rb', line 3

def code
  @code
end

#itemObject

Returns the value of attribute item.



2
3
4
# File 'lib/spud_core/errors.rb', line 2

def item
  @item
end

#request_urlObject

Returns the value of attribute request_url.



2
3
4
# File 'lib/spud_core/errors.rb', line 2

def request_url
  @request_url
end

#templateObject

Returns the value of attribute template.



2
3
4
# File 'lib/spud_core/errors.rb', line 2

def template
  @template
end

#titleObject (readonly)

Returns the value of attribute title.



3
4
5
# File 'lib/spud_core/errors.rb', line 3

def title
  @title
end