ruk·si

🛤️ Ruby on Rails
Custom Errors

Updated at 2015-09-09 00:57
# create file at `lib/errors.rb`
# or `gem_dir/lib/gem_name/errors.rb` if a gem
# note that module name and the filename must match
module Errors
    class InvalidUsername < StandardError; end
end
# edit `config/application.rb`
config.autoload_paths << Rails.root.join('lib')

Usage:

raise Errors::InvalidUsername

Sources