From d66df7f0b8fbf9e1193bfddd9765baeca177e5e8 Mon Sep 17 00:00:00 2001 From: 0x1eef <0x1eef@protonmail.com> Date: Thu, 29 Feb 2024 22:46:47 -0300 Subject: [PATCH] Raise an error when hbsdcontrol_set_feature_state failes --- ext/hbsdctl.rb/hbsdctl.c | 5 ++++- lib/bsd/control/feature.rb | 14 ++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/ext/hbsdctl.rb/hbsdctl.c b/ext/hbsdctl.rb/hbsdctl.c index ec93208..a7e662b 100644 --- a/ext/hbsdctl.rb/hbsdctl.c +++ b/ext/hbsdctl.rb/hbsdctl.c @@ -43,7 +43,10 @@ feature_set(VALUE self, VALUE path, VALUE state) if (r == 0) { return Qtrue; } else { - return Qfalse; + VALUE rb_mBSD = rb_const_get(rb_cObject, rb_intern("BSD")), + rb_mControl = rb_const_get(rb_mBSD, rb_intern("Control")), + rb_eError = rb_const_get(rb_mControl, rb_intern("Error")); + rb_raise(rb_eError, "hbsdcontrol_set_feature_state failed"); } } diff --git a/lib/bsd/control/feature.rb b/lib/bsd/control/feature.rb index 8185920..335aed5 100644 --- a/lib/bsd/control/feature.rb +++ b/lib/bsd/control/feature.rb @@ -8,10 +8,13 @@ module BSD::Control end ## - # Enables a feature for a given binary. + # Enables a feature for a given executable. # # @param [String] path - # The path to a binary. + # The path to an executable. + # + # @raise [BSD::Control::Error] + # When the operation fails. # # @return [Boolean] # Returns true on success. @@ -20,10 +23,13 @@ module BSD::Control end ## - # Disables a feature for a given binary. + # Disables a feature for a given executable. # # @param [String] path - # The path to a binary. + # The path to an executable. + # + # @raise [BSD::Control::Error] + # When the operation fails. # # @return [Boolean] # Returns true on success.