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