Example #1
0
        internal static void CheckException(RuntimeMethodHandle handle)
        {
            if (_staticreff != 0)
            {
                var method = MethodBase.GetMethodFromHandle(handle);
                var where = $"{method.DeclaringType.FullName}.{method.Name}";
                unsafe
                {
                    byte *errorptr;
                    int   ieff = 0;

                    Gmsh_Warp.GmshLoggerGetLastError(&errorptr, ref ieff);
                    if (ieff != 0)
                    {
                        throw new GmshException("Could not get last error", where, _staticreff);
                    }
                    else
                    {
                        var ptr   = new IntPtr(errorptr);
                        var error = Marshal.PtrToStringAnsi(ptr);
                        Gmsh_Warp.GmshFree(ptr);
                        throw new GmshException(error, where, _staticreff);
                    }
                }
            }
        }
Example #2
0
            /// <summary>
            /// Return last error message, if any.
            /// </summary>
            public static string GetLastError()
            {
                unsafe
                {
                    byte *errorptr;
                    Gmsh_Warp.GmshLoggerGetLastError(&errorptr, ref Gmsh._staticreff);

                    var ptr   = new IntPtr(errorptr);
                    var error = Marshal.PtrToStringAnsi(ptr);
                    Gmsh_Warp.GmshFree(ptr);

                    if (Gmsh._staticreff != 0)
                    {
                        var method = MethodBase.GetCurrentMethod();
                        var where = $"{method.DeclaringType.FullName}.{method.Name}";
                        throw new GmshException("Could not get last error", where, _staticreff);
                    }
                    return(error);
                }
            }