From f699351d95ee480e7e086b55fea8c6378bf197a4 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@uliege.be>
Date: Sun, 5 Jul 2020 11:19:19 +0200
Subject: [PATCH] handle gmsh.logger.getLastError special case in Julia as well

---
 api/GenApi.py | 7 +++++--
 api/gmsh.jl   | 2 +-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/api/GenApi.py b/api/GenApi.py
index 12df99eaed..5729c0aba5 100644
--- a/api/GenApi.py
+++ b/api/GenApi.py
@@ -1309,7 +1309,7 @@ class API:
                     fcwrap.write(", &ierr);\n")
                 else:
                     fcwrap.write("&ierr);\n")
-                if name == 'getLastError':
+                if name == 'getLastError': # special case for getLastError() function
                     fcwrap.write(indent + "  " + 'if(ierr) throw "Could not get last error";\n')
                 else:
                     fcwrap.write(indent + "  " + "if(ierr) throwLastError();\n")
@@ -1480,7 +1480,10 @@ class API:
                     ("," if not len(args) else "") + "),\n" + " " * 10 +
                     ", ".join(tuple(a.julia_arg
                                     for a in args) + ("ierr", )) + ")\n")
-            f.write('    ierr[] != 0 && error(gmsh.logger.getLastError())\n')
+            if name == "getLastError": # special case for getLastError() function
+                f.write('    ierr[] != 0 && error("Could not get last error")\n')
+            else:
+                f.write('    ierr[] != 0 && error(gmsh.logger.getLastError())\n')
             for a in args:
                 if a.julia_post: f.write("    " + a.julia_post + "\n")
             r = (["api_result_"]) if rtype else []
diff --git a/api/gmsh.jl b/api/gmsh.jl
index 96a2ded275..3c990bf22c 100644
--- a/api/gmsh.jl
+++ b/api/gmsh.jl
@@ -5667,7 +5667,7 @@ function getLastError()
     ccall((:gmshLoggerGetLastError, gmsh.lib), Cvoid,
           (Ptr{Ptr{Cchar}}, Ptr{Cint}),
           api_error_, ierr)
-    ierr[] != 0 && error(gmsh.logger.getLastError())
+    ierr[] != 0 && error("Could not get last error")
     error = unsafe_string(api_error_[])
     return error
 end
-- 
GitLab