Module: FFI::DRY::ErrnoHelper

Extended by:
Library
Included in:
FFI::DRY
Defined in:
lib/ffi/dry/errno.rb

Overview

This module lets us handle FFI-generated system call errors through ruby as exceptions using the Errno and SystemCallError exception classes.

This module is not automatically included in the runtime when you include ‘ffi/dry’. You must explicitely say

require 'ffi/dry/errno'

Instance Method Summary collapse

Methods included from Library

attach_optional_function

Instance Method Details

#errnoObject

An alias for FFI.errno



29
30
31
# File 'lib/ffi/dry/errno.rb', line 29

def errno
  FFI.errno
end

#errno_exception(arg = nil) ⇒ Object

Returns a ruby exception derived from the current value of errno. As per the intro(2) manpage, this should only ever be called after an error has been deteted from a function that sets the errno variable.



23
24
25
26
# File 'lib/ffi/dry/errno.rb', line 23

def errno_exception(arg=nil)
  err = self.errno
  return SystemCallError.new(arg, err)
end