tidy up custom exceptions
This commit is contained in:
parent
7a74431e88
commit
2947139632
@ -1,9 +1,6 @@
|
||||
require 'mixlib/shellout'
|
||||
|
||||
module Pacemaker
|
||||
class ObjectTypeMismatch < StandardError
|
||||
end
|
||||
|
||||
class CIBObject
|
||||
attr_accessor :name, :definition
|
||||
|
||||
@ -68,7 +65,8 @@ module Pacemaker
|
||||
@definition = self.class.get_definition(name)
|
||||
|
||||
if @definition and ! @definition.empty? and type != self.class.object_type
|
||||
raise ObjectTypeMismatch, "Expected #{self.class.object_type} type but loaded definition was type #{type}"
|
||||
raise CIBObject::TypeMismatch, \
|
||||
"Expected #{self.class.object_type} type but loaded definition was type #{type}"
|
||||
end
|
||||
end
|
||||
|
||||
@ -88,4 +86,10 @@ module Pacemaker
|
||||
"crm configure delete '#{name}'"
|
||||
end
|
||||
end
|
||||
|
||||
class CIBObject::DefinitionParseError < StandardError
|
||||
end
|
||||
|
||||
class CIBObject::TypeMismatch < StandardError
|
||||
end
|
||||
end
|
||||
|
@ -26,7 +26,8 @@ class Pacemaker::Resource::Primitive < Pacemaker::Resource
|
||||
|
||||
def parse_definition
|
||||
unless definition =~ /\Aprimitive (\S+) (\S+)/
|
||||
raise RuntimeError, "Couldn't parse definition '#{definition}'"
|
||||
raise Pacemaker::CIBObject::DefinitionParseError, \
|
||||
"Couldn't parse definition '#{definition}'"
|
||||
end
|
||||
self.name = $1
|
||||
self.agent = $2
|
||||
|
@ -14,7 +14,7 @@ describe Pacemaker::Resource::Primitive do
|
||||
.to receive(:stdout) \
|
||||
.and_return("clone foo blah blah")
|
||||
expect { @primitive.load_definition }.to \
|
||||
raise_error(Pacemaker::ObjectTypeMismatch,
|
||||
raise_error(Pacemaker::CIBObject::TypeMismatch,
|
||||
"Expected primitive type but loaded definition was type clone")
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user