class SystemCallError
SystemCallError is the base class for all low-level platform-dependent errors.
The errors available on the current platform are subclasses of SystemCallError and are defined in the Errno module.
File.open("does/not/exist")
raises the exception:
Errno::ENOENT: No such file or directory - does/not/exist
Public Class Methods
(untyped other) → bool
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/core/errors.rbs, line 636
def self.===: (untyped other) -> bool
Return true if the receiver is a generic SystemCallError, or if the error numbers self and other are the same.
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/core/errors.rbs, line 627
def initialize: (string msg, Integer errno) -> void
If errno corresponds to a known system error code, constructs the appropriate Errno class for that error, otherwise constructs a generic SystemCallError object. The error number is subsequently available via the
errno method.
If only numeric object is given, it is treated as an Integer errno, and msg is omitted, otherwise the first argument msg is used as the additional error message.
SystemCallError.new(Errno::EPIPE::Errno) #=> #<Errno::EPIPE: Broken pipe> SystemCallError.new("foo") #=> #<SystemCallError: unknown error - foo> SystemCallError.new("foo", Errno::EPIPE::Errno) #=> #<Errno::EPIPE: Broken pipe - foo>
If func is not nil, it is appended to the message with “ @ ”.
SystemCallError.new("foo", Errno::EPIPE::Errno, "here") #=> #<Errno::EPIPE: Broken pipe @ here - foo>
A subclass of SystemCallError can also be instantiated via the new method of the subclass. See Errno.