]> git.tdb.fi Git - r2c2.git/blobdiff - source/libr2c2/vehicle.cpp
Create a dedicated exception class for vehicle attachment errors
[r2c2.git] / source / libr2c2 / vehicle.cpp
index 6b89fa8743b604036ccab17c7a42a48e94e8c208..cf00c7706e3e991a9acc53d607f7c56798bb5595 100644 (file)
@@ -41,7 +41,7 @@ Vehicle::~Vehicle()
 void Vehicle::attach_back(Vehicle &veh)
 {
        if(next || veh.prev)
-               throw InvalidState("Already attached");
+               throw attachment_error("already attached");
 
        next = &veh;
        veh.prev = this;
@@ -53,7 +53,7 @@ void Vehicle::attach_back(Vehicle &veh)
 void Vehicle::attach_front(Vehicle &veh)
 {
        if(prev || veh.next)
-               throw InvalidState("Already attached");
+               throw attachment_error("already attached");
 
        prev = &veh;
        veh.next = this;
@@ -65,7 +65,7 @@ void Vehicle::attach_front(Vehicle &veh)
 void Vehicle::detach_back()
 {
        if(!next)
-               throw InvalidState("Not attached");
+               throw attachment_error("not attached");
 
        next->prev = 0;
        next = 0;
@@ -74,7 +74,7 @@ void Vehicle::detach_back()
 void Vehicle::detach_front()
 {
        if(!prev)
-               throw InvalidState("Not attached");
+               throw attachment_error("not attached");
 
        prev->next = 0;
        prev = 0;