Defining custom errors in Ruby

Updated . Posted . Visible to the public.
class Errormaster
  CoffeeIsOut = Class.new(StandardError)
  
  # is prettier than
  class CoffeeIsOut < StandardError; end
end

Reference such an error class with Errormaster::CoffeeIsOut.

Dominik Schöler
Last edit
Keywords
Rails, exception
License
Source code in this card is licensed under the MIT License.
Posted by Dominik Schöler to makandra dev (2011-09-09 12:39)