Module: Adept::LowLevel::ErrorHandler
- Extended by:
- FFI::Library
- Defined in:
- lib/adept/low_level/error_handler.rb
Overview
Basic low-level error handler.
This class implements the basic error reporting functionality from the Digilent Device Manager API. It is intentionally separate from the low-level DeviceManager wrapper, so error checking works even if the AdeptLibrary class fails during development.
Class Method Summary collapse
-
.last_error ⇒ Object
Returns a DeviceError which encapsulates the most recent error, in a format which can be easily raised.
Class Method Details
.last_error ⇒ Object
Returns a DeviceError which encapsulates the most recent error, in a format which can be easily raised.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/adept/low_level/error_handler.rb', line 37 def self.last_error #get the error code most recently seen by the device manager API. code = DmgrGetLastError() #if no error has occurred, return nil. return nil if code.zero? #Create space for the error name and message... error_name = FFI::MemoryPointer.new(ErrorNameMaxLength) = FFI::MemoryPointer.new(ErrorMessageMaxLength) #... and populate those spaces with the relevant error information. DmgrSzFromErc(code, error_name, ) #Convert the error information into a DeviceError. DeviceError.new(.read_string, error_name.read_string, code) end |