aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Richard Brown <rbrown@exherbo.org> 2007-01-20 17:09:29 +0000
committerAvatar Richard Brown <rbrown@exherbo.org> 2007-01-20 17:09:29 +0000
commitba480587d5e2f3a908d8a69f9eb6a9c9e5e56fdf (patch)
tree9aa1f477caefe4592469d5db433b50019f0510cc
parent13637e6fa3570dcfc98b6ceaf185b6dda8875c2c (diff)
downloadpaludis-ba480587d5e2f3a908d8a69f9eb6a9c9e5e56fdf.tar.gz
paludis-ba480587d5e2f3a908d8a69f9eb6a9c9e5e56fdf.tar.xz
Improve ruby AllMaskedError.
-rw-r--r--ruby/dep_list_TEST.rb6
-rw-r--r--ruby/paludis_ruby.cc38
2 files changed, 43 insertions, 1 deletions
diff --git a/ruby/dep_list_TEST.rb b/ruby/dep_list_TEST.rb
index eb186a4..494c145 100644
--- a/ruby/dep_list_TEST.rb
+++ b/ruby/dep_list_TEST.rb
@@ -204,6 +204,12 @@ module Paludis
assert_raise AllMaskedError do
dl.add(PackageDepAtom.new('foo/ba'))
end
+ begin
+ dl.add(PackageDepAtom.new('foo/ba'))
+ rescue AllMaskedError => error
+ assert_equal 'foo/ba', error.query
+ end
+
end
def test_options
diff --git a/ruby/paludis_ruby.cc b/ruby/paludis_ruby.cc
index 406c0d4..c5a3f16 100644
--- a/ruby/paludis_ruby.cc
+++ b/ruby/paludis_ruby.cc
@@ -163,7 +163,12 @@ void paludis::ruby::exception_to_ruby_exception(const std::exception & ee)
else if (0 != dynamic_cast<const paludis::DepStringError *>(&ee))
rb_raise(c_dep_string_error, dynamic_cast<const paludis::DepStringError *>(&ee)->message().c_str());
else if (0 != dynamic_cast<const paludis::AllMaskedError *>(&ee))
- rb_raise(c_all_masked_error, dynamic_cast<const paludis::AllMaskedError *>(&ee)->message().c_str());
+ {
+ VALUE ex_args[2];
+ ex_args[0] = rb_str_new2(dynamic_cast<const paludis::AllMaskedError *>(&ee)->message().c_str());
+ ex_args[1] = rb_str_new2(dynamic_cast<const paludis::AllMaskedError *>(&ee)->query().c_str());
+ rb_exc_raise(rb_class_new_instance(2, ex_args, c_all_masked_error));
+ }
else if (0 != dynamic_cast<const paludis::BlockError *>(&ee))
rb_raise(c_block_error, dynamic_cast<const paludis::BlockError *>(&ee)->message().c_str());
else if (0 != dynamic_cast<const paludis::CircularDependencyError *>(&ee))
@@ -244,6 +249,29 @@ paludis::ruby::paludis_qa_module()
}
#endif
+static VALUE
+all_masked_error_init(int argc, VALUE* argv, VALUE self)
+{
+ VALUE query;
+
+ query = (argc > 1) ? argv[--argc] : Qnil;
+ rb_call_super(argc, argv);
+ rb_iv_set(self, "query", query);
+ return self;
+}
+
+/*
+ * call-seq:
+ * query -> String or Nil
+ *
+ * Our query.
+ */
+VALUE
+all_masked_error_query(VALUE self)
+{
+ return rb_attr_get(self, rb_intern("query"));
+}
+
extern "C"
{
void Init_Paludis()
@@ -275,7 +303,15 @@ extern "C"
c_configuration_error = rb_define_class_under(c_paludis_module, "ConfigurationError", rb_eRuntimeError);
c_config_file_error = rb_define_class_under(c_paludis_module, "ConfigFileError", c_configuration_error);
c_dep_list_error = rb_define_class_under(c_paludis_module, "DepListError", rb_eRuntimeError);
+
+ /*
+ * Document-class: Paludis::AllMaskedError
+ *
+ * Thrown if all versions of a particular atom are masked.
+ */
c_all_masked_error = rb_define_class_under(c_paludis_module, "AllMaskedError", c_dep_list_error);
+ rb_define_method(c_all_masked_error, "initialize", RUBY_FUNC_CAST(&all_masked_error_init), -1);
+ rb_define_method(c_all_masked_error, "query", RUBY_FUNC_CAST(&all_masked_error_query), 0);
c_block_error = rb_define_class_under(c_paludis_module, "BlockError", c_dep_list_error);
c_circular_dependency_error = rb_define_class_under(c_paludis_module, "CircularDependencyError", c_dep_list_error);
c_use_requirements_not_met_error = rb_define_class_under(c_paludis_module, "UseRequirementsNotMetError", c_dep_list_error);