Skip to content

Commit

Permalink
Merge pull request #38 from ros/improve_error_messages
Browse files Browse the repository at this point in the history
make error messages tool specific
  • Loading branch information
dirk-thomas committed Apr 14, 2014
2 parents adb2ef9 + e1bcabe commit 6c68078
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
10 changes: 10 additions & 0 deletions include/rospack/rospack.h
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,12 @@ re-run the profile with --zombie-only
*/
void logError(const std::string& msg,
bool append_errno = false);

/*
* @brief The manifest type.
* @return Either "package" or "stack".
*/
virtual std::string get_manifest_type() { return ""; }
};

/**
Expand All @@ -546,6 +552,8 @@ class ROSPACK_DECL Rospack : public Rosstackage
* @return Command-line usage for the rospack tool.
*/
virtual const char* usage();

virtual std::string get_manifest_type();
};

/**
Expand All @@ -564,6 +572,8 @@ class ROSPACK_DECL Rosstack : public Rosstackage
* @return Command-line usage for the rosstack tool.
*/
virtual const char* usage();

virtual std::string get_manifest_type();
};

} // namespace rospack
Expand Down
16 changes: 13 additions & 3 deletions src/rospack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1204,7 +1204,7 @@ Rosstackage::findWithRecrawl(const std::string& name)
return stackages_[name];
}

logError(std::string("stack/package ") + name + " not found");
logError(get_manifest_type() + " '" + name + "' not found");
return NULL;
}

Expand Down Expand Up @@ -1609,7 +1609,7 @@ Rosstackage::computeDepsInternal(Stackage* stackage, bool ignore_errors, const s
{
if(!ignore_errors)
{
std::string errmsg = std::string("package/stack ") + stackage->name_ + " depends on itself";
std::string errmsg = get_manifest_type() + " '" + stackage->name_ + "' depends on itself";
throw Exception(errmsg);
}
}
Expand All @@ -1626,7 +1626,7 @@ Rosstackage::computeDepsInternal(Stackage* stackage, bool ignore_errors, const s
}
else
{
std::string errmsg = std::string("package/stack '") + stackage->name_ + "' depends on non-existent package '" + dep_pkgname + "' and rosdep claims that it is not a system dependency. Check the ROS_PACKAGE_PATH or try calling 'rosdep update'";
std::string errmsg = get_manifest_type() + " '" + stackage->name_ + "' depends on non-existent package '" + dep_pkgname + "' and rosdep claims that it is not a system dependency. Check the ROS_PACKAGE_PATH or try calling 'rosdep update'";
throw Exception(errmsg);
}
}
Expand Down Expand Up @@ -2260,6 +2260,11 @@ Rospack::usage()
" is used (if it contains a manifest.xml).\n\n";
}

std::string Rospack::get_manifest_type()
{
return "package";
}

/////////////////////////////////////////////////////////////
// Rosstack methods
/////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -2295,6 +2300,11 @@ Rosstack::usage()
" is used (if it contains a stack.xml).\n\n";
}

std::string Rosstack::get_manifest_type()
{
return "stack";
}

TiXmlElement*
get_manifest_root(Stackage* stackage)
{
Expand Down
12 changes: 6 additions & 6 deletions src/rospack_cmdline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ rospack_run(int argc, char** argv, rospack::Rosstackage& rp, std::string& output
{
if(!package.size())
{
rp.logError( "no package/stack given");
rp.logError(std::string("no ") + rp.get_manifest_type() + " given");
return false;
}
if(target.size() || top.size() || length_str.size() ||
Expand Down Expand Up @@ -354,7 +354,7 @@ rospack_run(int argc, char** argv, rospack::Rosstackage& rp, std::string& output
{
if(!package.size())
{
rp.logError( "no package/stack given");
rp.logError(std::string("no ") + rp.get_manifest_type() + " given");
return false;
}
if(target.size() || top.size() || length_str.size() ||
Expand All @@ -377,7 +377,7 @@ rospack_run(int argc, char** argv, rospack::Rosstackage& rp, std::string& output
{
if(!package.size())
{
rp.logError( "no package/stack given");
rp.logError(std::string("no ") + rp.get_manifest_type() + " given");
return false;
}
if(target.size() || top.size() || length_str.size() ||
Expand Down Expand Up @@ -434,7 +434,7 @@ rospack_run(int argc, char** argv, rospack::Rosstackage& rp, std::string& output
{
if(!package.size())
{
rp.logError( "no package/stack given");
rp.logError(std::string("no ") + rp.get_manifest_type() + " given");
return false;
}
if(target.size() || top.size() || length_str.size() ||
Expand All @@ -457,7 +457,7 @@ rospack_run(int argc, char** argv, rospack::Rosstackage& rp, std::string& output
{
if(!package.size() || !target.size())
{
rp.logError( "no package/stack or target given");
rp.logError(std::string("no ") + rp.get_manifest_type() + " or target given");
return false;
}
if(top.size() || length_str.size() ||
Expand Down Expand Up @@ -529,7 +529,7 @@ rospack_run(int argc, char** argv, rospack::Rosstackage& rp, std::string& output
{
if(!package.size())
{
rp.logError( "no package/stack given");
rp.logError(std::string("no ") + rp.get_manifest_type() + " given");
return false;
}
if(target.size() || top.size() || length_str.size() ||
Expand Down

0 comments on commit 6c68078

Please # to comment.