org.bridj
Class LastError

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Error
          extended by org.bridj.NativeError
              extended by org.bridj.LastError
All Implemented Interfaces:
Serializable

public class LastError
extends NativeError

Native error that correspond to the errno or GetLastError() mechanism.
Some C functions declare errors by marking an error code in errno or through SetLastError(int).
If you want their corresponding bindings to throw an exception whenever such an error was marked, simply make them throw this exception explicitly.
On Windows, BridJ will first check GetLastError(), then if no error was found it will check errno (on the other platforms only errno is available).
For instance, look at the following binding of the C-library strtoul function :

 @Library("c")
 public static native long strtoul(Pointer<Byte> str, Pointer<Pointer<Byte>> endptr, int base) throws LastError;
 

Author:
Olivier Chafik
See Also:
Serialized Form

Method Summary
 int getCode()
          Native error code (as returned by errno or GetLastError()).
 String getDescription()
          Native error description (as returned by strerror or FormatMessage).
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getCode

public int getCode()
Native error code (as returned by errno or GetLastError()).


getDescription

public String getDescription()
Native error description (as returned by strerror or FormatMessage).



Copyright © 2009-2012. All Rights Reserved.