Exception: TbCore::RequestError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/tb_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



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

def initialize(item_or_opts='page', opts={})
  if item_or_opts.is_a?(Hash)
    @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.



5
6
7
# File 'lib/tb_core/errors.rb', line 5

def code
  @code
end

#itemObject

Returns the value of attribute item.



4
5
6
# File 'lib/tb_core/errors.rb', line 4

def item
  @item
end

#request_urlObject

Returns the value of attribute request_url.



4
5
6
# File 'lib/tb_core/errors.rb', line 4

def request_url
  @request_url
end

#templateObject

Returns the value of attribute template.



4
5
6
# File 'lib/tb_core/errors.rb', line 4

def template
  @template
end

#titleObject (readonly)

Returns the value of attribute title.



5
6
7
# File 'lib/tb_core/errors.rb', line 5

def title
  @title
end