summaryrefslogtreecommitdiffstats
path: root/state.rb
diff options
context:
space:
mode:
authorCasey Dahlin <cdahlin@redhat.com>2008-11-07 15:15:08 -0500
committerCasey Dahlin <cdahlin@redhat.com>2008-11-07 15:15:08 -0500
commit2c628ecf2332b6d2a6df59e215b3777d2fddbc35 (patch)
treea9f807a589021beaefea906cc3d0eeae49a16b19 /state.rb
parentbeb71e9849eafaa1de97d274725a5e9c5264da30 (diff)
downloadupstate-2c628ecf2332b6d2a6df59e215b3777d2fddbc35.tar.gz
upstate-2c628ecf2332b6d2a6df59e215b3777d2fddbc35.tar.xz
upstate-2c628ecf2332b6d2a6df59e215b3777d2fddbc35.zip
Annotate TypeErrors
Several locations which through TypeError on invalid argument now further explain the error.
Diffstat (limited to 'state.rb')
-rw-r--r--state.rb14
1 files changed, 7 insertions, 7 deletions
diff --git a/state.rb b/state.rb
index bbae606..cf54f75 100644
--- a/state.rb
+++ b/state.rb
@@ -122,7 +122,7 @@ class State
hold = Hold::Dep.new(hold) if hold.is_a? State
hold = Hold::User.new(params) if hold == :user
hold = Hold::System.new(params) if hold == :system
- raise TypeError unless hold.is_a? Hold
+ raise TypeError, "Invalid hold specifier" unless hold.is_a? Hold
if @status == :down and self.class.hold_provides.size > 0
return self.fork(hold)
end
@@ -158,7 +158,7 @@ class State
hold = Hold::Dep.new(hold) if hold.is_a? State
hold = Hold::User.new(params) if hold == :user
hold = Hold::System.new(params) if hold == :system
- raise TypeError unless hold.is_a? Hold
+ raise TypeError, "Invalid hold specifier" unless hold.is_a? Hold
@holds.reject!{ |x| hold == x }
drop if @holds.size == 0
self
@@ -241,7 +241,7 @@ class State
# Handle the occurance of an event. This method is not defined in subclasses
# of State.
def State.process_event(event)
- raise TypeError unless event.is_a? Event
+ raise TypeError, "Argument must be an Event" unless event.is_a? Event
count = 0
@@states.select{ |x| x.status == :down }.each do |x|
next unless x.react_to? event
@@ -324,7 +324,7 @@ class Hold
# +params+ should be a hash of parameters.
def initialize(params = {})
raise NoMethodError if self.class == Hold
- raise TypeError unless params.is_a? Hash
+ raise TypeError, "Parameters must be a hash" unless params.is_a? Hash
@params = params
end
@@ -355,7 +355,7 @@ class Hold
class Dep < Hold
# +dependent+ must be an object of type State
def initialize(dependent)
- raise TypeError unless dependent.is_a? State
+ raise TypeError, "Dependent must be a State" unless dependent.is_a? State
@dependent = dependent
end
@@ -398,8 +398,8 @@ class Dependency
# parameters. The parameters in the hash can be string values to match or
# Regex objects
def initialize(stateclass, params = {}, remap = {})
- raise TypeError unless State > stateclass
- raise TypeError unless params.is_a? Hash
+ raise TypeError, "Class must be a State Class" unless State > stateclass
+ raise TypeError, "Params must be a hash" unless params.is_a? Hash
@stateclass = stateclass
@params = params
@remap = remap