Skip to content
class method

SystemCallError.new

(::string msg, ::Integer errno) -> ::SystemCallError
SystemCallError.new(msg, errno = nil, func = nil) → system_call_error_subclass

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.

Example
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 “ @ ”.

Example
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.

See also .=== #errno also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0