module ExceptionNotification::CustomExceptionMethods

Copyright © 2008-2009 Peter H. Boling of 9thBit LLC Released under the MIT license

Protected Instance Methods

access_denied() click to toggle source

The current user does not have enough privileges to access the requested resource

# File lib/exception_notification/custom_exception_methods.rb, line 34
def access_denied
  raise AccessDenied
end
corrupt_data() click to toggle source

If your ever at a spot in the code that should never get reached, but corrupt data might get you there anyways then this is for you:

# File lib/exception_notification/custom_exception_methods.rb, line 21
def corrupt_data
  raise CorruptData
end
generic_error() click to toggle source
# File lib/exception_notification/custom_exception_methods.rb, line 38
def generic_error
  error_stickie("Sorry, an error has occurred.")
  corrupt_data
end
invalid_method() click to toggle source

Resources that must be requested with a specific HTTP Method (GET, PUT, POST, DELETE, AJAX, etc) but are requested otherwise should:

# File lib/exception_notification/custom_exception_methods.rb, line 17
def invalid_method
  raise InvalidMethod
end
invalid_page() click to toggle source
# File lib/exception_notification/custom_exception_methods.rb, line 43
def invalid_page
  error_stickie("Sorry, the page number you requested was not valid.")
  page_not_found
end
method_disabled() click to toggle source
# File lib/exception_notification/custom_exception_methods.rb, line 30
def method_disabled
  raise MethodDisabled
end
not_implemented() click to toggle source

Then for things that have never existed or have not for a long time we call not_implemented

# File lib/exception_notification/custom_exception_methods.rb, line 13
def not_implemented
  raise NotImplemented
end
page_not_found() click to toggle source
# File lib/exception_notification/custom_exception_methods.rb, line 24
def page_not_found
  raise PageNotFound
end
record_not_found() click to toggle source
# File lib/exception_notification/custom_exception_methods.rb, line 27
def record_not_found
  raise ActiveRecord::RecordNotFound
end
resource_gone() click to toggle source

For a while after disabling a route/URL that had been functional we should set it to resource gone to inform people to remove bookmarks.

# File lib/exception_notification/custom_exception_methods.rb, line 9
def resource_gone
  raise ResourceGone
end