Exception: Zookeeper::Exceptions::ZookeeperException

Inherits:
StandardError
  • Object
show all
Defined in:
lib/zookeeper/exceptions.rb

Constant Summary collapse

CONST_MISSING_WARNING =
"\n------------------------------------------------------------------------------------------\nWARNING! THE ZOOKEEPER NAMESPACE HAS CHNAGED AS OF 1.0!\n\nPlease update your code to use the new heirarchy!\n\nThe constant that got you this was ZookeeperExceptions::ZookeeperException::%s\n\nstacktrace:\n%s\n\n------------------------------------------------------------------------------------------\n\n"

Class Method Summary collapse

Class Method Details

.const_missing(const) ⇒ Object

NOTE(slyphon): Since 0.4 all of the ZookeeperException subclasses were

defined inside of ZookeeperException, which always seemed well, icky.
if someone references one of these we'll print out a warning and 
then give them the constant

31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/zookeeper/exceptions.rb', line 31

def self.const_missing(const)
  if Zookeeper::Exceptions.const_defined?(const)

    stacktrace = caller[0..-2].reject {|n| n =~ %r%/rspec/% }.map { |n| "\t#{n}" }.join("\n")

    Zookeeper.deprecation_warning(CONST_MISSING_WARNING % [const.to_s, stacktrace])


    Zookeeper::Exceptions.const_get(const).tap do |const_val|
      self.const_set(const, const_val)
    end
  else
    super
  end
end