public static void GetLastErrorInfo(ref FPErrorInfo outErrorInfo) { unsafe { var ptr = (IntPtr)Marshal.AllocHGlobal((int)1024).ToPointer(); /* Get the error message of the last SDK API function call */ SDK.FPPool_GetLastErrorInfo(ptr); outErrorInfo = (FPErrorInfo)Marshal.PtrToStructure(ptr, typeof(FPErrorInfo)); Marshal.FreeHGlobal(ptr); } SDK.CheckAndThrowError(); }
/// <summary> /// Generic error checking routine for transforming SDK errors into .NET exceptions /// </summary> public static void CheckAndThrowError() { /* Get the error code of the last SDK API function call */ var errorCode = SDK.FPPool_GetLastError(); if (0 != errorCode) { var errInfo = new FPErrorInfo(); unsafe { var ptr = (IntPtr)Marshal.AllocHGlobal((int)1024).ToPointer(); /* Get the error message of the last SDK API function call */ SDK.FPPool_GetLastErrorInfo(ptr); errInfo = (FPErrorInfo)Marshal.PtrToStructure(ptr, typeof(FPErrorInfo)); Marshal.FreeHGlobal(ptr); } throw new FPLibraryException(errInfo); } }
internal ErrorInfo(FPErrorInfo errorInfo) => this.errorInfo = errorInfo;
internal ErrorInfo(FPErrorInfo errorInfo) { _errorInfo = errorInfo; }