Sha256: d1f137874b02c73b21f9fa7bbadf025d291a934040879001e5f49d75934f722a
Contents?: true
Size: 1.47 KB
Versions: 6
Compression:
Stored size: 1.47 KB
Contents
class Spud::RequestError < StandardError attr_accessor :request_url, :item, :template attr_reader :code, :title # 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 # 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 end class Spud::AccessDeniedError < Spud::RequestError def initialize(item_or_opts='page', opts={}) @code = 403 @i18n = 'access_denied' super(item_or_opts, opts) end end class Spud::NotFoundError < Spud::RequestError def initialize(item_or_opts='page', opts={}) @code = 404 @i18n = 'not_found' super(item_or_opts, opts) end end class Spud::UnauthorizedError < Spud::RequestError def initialize(item_or_opts='page', opts={}) @code = 401 @i18n = 'unauthorized' super(item_or_opts, opts) end end
Version data entries
6 entries across 6 versions & 1 rubygems