Here is a simple method of defining custom errors in rails. A strategy that works well for us is to create an ApplicationError module, then define errors classes within it.

# application_error.rb

module ApplicationError
  CustomError      =
  OtherCustomError =

Then to use the newly defined class:

raise'custom message')

We found this to be a neat and organized way to add custom classes, and there are likely many other features you could build into it but this approach worked well for us.