diff --git a/src/Task.cpp b/src/Task.cpp index 635d9a04f..9e1309a65 100644 --- a/src/Task.cpp +++ b/src/Task.cpp @@ -801,6 +801,11 @@ void Task::addDependency (const std::string& uuid) if (uuid == get ("uuid")) throw std::string (STRING_TASK_DEPEND_ITSELF); + // Check that uuid is resolvable. + int id = context.tdb2.pending.id (uuid); + if (id == 0) + throw format (STRING_TASK_DEPEND_MISS_CREA, id); + // Store the dependency. std::string depends = get ("depends"); if (depends != "") @@ -837,6 +842,8 @@ void Task::removeDependency (const std::string& uuid) set ("depends", combined); recalc_urgency = true; } + else + throw format (STRING_TASK_DEPEND_MISS_DEL, uuid); } //////////////////////////////////////////////////////////////////////////////// diff --git a/test/dependencies.t b/test/dependencies.t index ac5024765..de4aa9b8f 100755 --- a/test/dependencies.t +++ b/test/dependencies.t @@ -50,7 +50,7 @@ qx{../src/task rc:dep.rc add Two}; # [2] my $output = qx{../src/task rc:dep.rc 1 modify dep:-2}; -like ($output, qr/Modified 0 tasks\./, 'dependencies - remove nonexistent dependency'); +like ($output, qr/Could not delete a dependency on task 2 - not found\./, 'dependencies - remove nonexistent dependency'); # [3] $output = qx{../src/task rc:dep.rc 1 modify dep:99};