karamba3d / K3D_NightlyBuilds

Nightly build versions of Karamba3d
https://karamba3d.com
25 stars 2 forks source link

BUG: Scripting: AnalyzeThI crash when model license is not valid #65

Open Ludovic-Regnault opened 1 year ago

Ludovic-Regnault commented 1 year ago

Describe the bug When the AnalyzeThI.solve Method runs on a model with an invalid license, an error occurs. From unity it evens makes the app crash.

Fix: Could the method throw an exception indicating that the license is not valid, instead of crashing the app? Or/And Describe in the API that the method requires to have a valid license, that can be checked with License.license_is_valid Method

To Reproduce

  1. Construct a model with more than 20 members
  2. Launch AnalyzeThI.solve Method with no valid license
  3. see crash/exception

Notes This is the message generated from Unity: image

Clemens-Preisinger commented 1 year ago

Hello Ludovic, exceptional states in Karamba3D are handled by throwing exceptions which transform into an error message in Grasshopper. You could wrap your code in a try-catch block when working in Unity. -- Clemens

Ludovic-Regnault commented 1 year ago

Yes, but i did implement try-catch around the AnalyzeTHI method (circled in red i the screenshot) and the unity app would crash despite the try-catch It is only when i test if "license_is_valid()" before that the code runs without crashing image

Clemens-Preisinger commented 1 year ago

Thanks for the hint.

The exception comes from the C++ part and cannot be properly handled by C# as it seems.

If someone has in depth experience with SWIG and exception handling any tips on improving the situation would be highly appreciated.

-- Clemens