Exception: Seccomp::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Seccomp::Error
- Defined in:
- lib/seccomp/errors.rb
Overview
Base error carrying the libseccomp errno and C call name.
Direct Known Subclasses
ArchError, ClosedFilterError, ExistsError, InvalidArgumentError, KernelError, NotFoundError, NotSupportedError, NotificationError, OutOfMemoryError, PermissionError, ThreadSyncError, UnknownSyscallError, ValueRangeError
Constant Summary collapse
- ERRORS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
errno-to-exception lookup.
{ Errno::EACCES::Errno => :PermissionError, Errno::ECANCELED::Errno => :KernelError, Errno::EDOM::Errno => :ArchError, Errno::EEXIST::Errno => :ExistsError, Errno::EINVAL::Errno => :InvalidArgumentError, Errno::ENOENT::Errno => :NotFoundError, Errno::ENOMEM::Errno => :OutOfMemoryError, Errno::EOPNOTSUPP::Errno => :NotSupportedError, Errno::ERANGE::Errno => :ValueRangeError, Errno::ESRCH::Errno => :ThreadSyncError }.freeze
Instance Attribute Summary collapse
-
#call ⇒ Object
readonly
Returns the value of attribute call.
-
#errno ⇒ Object
readonly
Returns the value of attribute errno.
Class Method Summary collapse
-
.check!(result, call:, hint: nil) ⇒ Integer
Nonnegative result.
Instance Method Summary collapse
Constructor Details
#initialize(message = nil, errno: nil, call: nil) ⇒ void
28 29 30 31 32 |
# File 'lib/seccomp/errors.rb', line 28 def initialize( = nil, errno: nil, call: nil) @errno = errno @call = call super() end |
Instance Attribute Details
#call ⇒ Object (readonly)
Returns the value of attribute call.
6 7 8 |
# File 'lib/seccomp/errors.rb', line 6 def call @call end |
#errno ⇒ Object (readonly)
Returns the value of attribute errno.
6 7 8 |
# File 'lib/seccomp/errors.rb', line 6 def errno @errno end |
Class Method Details
.check!(result, call:, hint: nil) ⇒ Integer
Returns nonnegative result.
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/seccomp/errors.rb', line 40 def self.check!(result, call:, hint: nil) return result unless result.negative? errno = -result name = Errno.constants.find do |constant| error_class = Errno.const_get(constant) error_class.is_a?(Class) && error_class < SystemCallError && errno == error_class::Errno end klass = Seccomp.const_get(ERRORS.fetch(errno, :Error)) = "#{call} failed: #{name || "errno #{errno}"}" += " (#{hint})" if hint raise klass.new(, errno: errno, call: call) end |