aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-10-26 09:22:49 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-10-26 09:22:49 +0000
commit3f85010b680fa12c91b1f22817ddc2701a699fcf (patch)
tree6023b51f99942130e6cae93c21727454b45e05a9
parent98a6becac52ccf6508ab284adaaad83929dd65c5 (diff)
downloadpaludis-3f85010b680fa12c91b1f22817ddc2701a699fcf.tar.gz
paludis-3f85010b680fa12c91b1f22817ddc2701a699fcf.tar.xz
More dep parser exception handling. From Richard Brown
-rw-r--r--ruby/paludis_ruby.cc8
-rw-r--r--ruby/portage_dep_parser_TEST.rb10
2 files changed, 16 insertions, 2 deletions
diff --git a/ruby/paludis_ruby.cc b/ruby/paludis_ruby.cc
index 7d61ab0..ccd64f6 100644
--- a/ruby/paludis_ruby.cc
+++ b/ruby/paludis_ruby.cc
@@ -46,6 +46,8 @@ namespace
static VALUE c_no_such_package_error;
static VALUE c_no_such_repository_error;
static VALUE c_dep_string_error;
+ static VALUE c_dep_string_parse_error;
+ static VALUE c_dep_string_nesting_error;
}
RegisterRubyClass::RegisterRubyClass() :
@@ -87,6 +89,10 @@ void paludis::ruby::exception_to_ruby_exception(const std::exception & ee)
rb_raise(c_package_database_lookup_error, dynamic_cast<const paludis::PackageDatabaseLookupError *>(&ee)->message().c_str());
else if (0 != dynamic_cast<const paludis::PackageDatabaseError *>(&ee))
rb_raise(c_package_database_error, dynamic_cast<const paludis::PackageDatabaseError *>(&ee)->message().c_str());
+ else if (0 != dynamic_cast<const paludis::DepStringNestingError *>(&ee))
+ rb_raise(c_dep_string_nesting_error, dynamic_cast<const paludis::DepStringNestingError *>(&ee)->message().c_str());
+ else if (0 != dynamic_cast<const paludis::DepStringParseError *>(&ee))
+ rb_raise(c_dep_string_parse_error, dynamic_cast<const paludis::DepStringParseError *>(&ee)->message().c_str());
else if (0 != dynamic_cast<const paludis::DepStringError *>(&ee))
rb_raise(c_dep_string_error, dynamic_cast<const paludis::DepStringError *>(&ee)->message().c_str());
@@ -139,6 +145,8 @@ extern "C"
c_no_such_package_error = rb_define_class_under(c_master_class, "NoSuchPackageError", c_package_database_lookup_error);
c_no_such_repository_error = rb_define_class_under(c_master_class, "NoSuchRepositoryError", c_package_database_lookup_error);
c_dep_string_error = rb_define_class_under(c_master_class, "DepStringError", rb_eRuntimeError);
+ c_dep_string_parse_error = rb_define_class_under(c_master_class, "DepStringParseError", c_dep_string_error);
+ c_dep_string_nesting_error = rb_define_class_under(c_master_class, "DepStringNestingError", c_dep_string_parse_error);
rb_define_const(c_master_class, "Version", rb_str_new2((stringify(PALUDIS_VERSION_MAJOR) + "."
+ stringify(PALUDIS_VERSION_MINOR) + "." + stringify(PALUDIS_VERSION_MICRO)).c_str()));
diff --git a/ruby/portage_dep_parser_TEST.rb b/ruby/portage_dep_parser_TEST.rb
index 7593205..dd08db2 100644
--- a/ruby/portage_dep_parser_TEST.rb
+++ b/ruby/portage_dep_parser_TEST.rb
@@ -56,18 +56,24 @@ class Paludis
assert_equal "foo/monkey", atom.to_a[0].to_s
assert_kind_of PackageDepAtom, atom.to_a[0]
- assert_raise DepStringError do
+ assert_raise DepStringParseError do
PortageDepParser::parse("|| ( foo/bar )", PortageDepParser::PackageDepAtom, false)
end
PortageDepParser::parse("|| ( foo/bar )", PortageDepParser::PackageDepAtom, true)
- assert_raise DepStringError do
+ assert_raise DepStringParseError do
PortageDepParser::parse("|| ( foo/bar )", PortageDepParser::PlainTextDepAtom, false)
end
PortageDepParser::parse("|| ( foo/bar )", PortageDepParser::PlainTextDepAtom, true)
end
+
+ def test_dep_string_nesting_error
+ assert_raise DepStringNestingError do
+ PortageDepParser::parse("|| ( foo/var ", PortageDepParser::PackageDepAtom,true)
+ end
+ end
end
end