How should I handle exceptions in my plugins? I tried using various libraries and in some cases they can break Godot, which leads to the program crashing.

O3ZY changed the title to Crash handling in GDExtension plugin .

Don't intentionally throw exceptions from your plugin unless there's no other recourse. If you are calling into a library function that is unsafe, it makes sense IMO to try/catch around that, but otherwise it's better to predict possible errors, do good type/null/etc checking, and print the error and return null/empty/ERROR_CODE/etc if there's an issue.

  • O3ZY replied to this.

    award I tried using try/catch(...) but something happens inside the called function that breaks the program and does not exit in catch.

      award It's Assimp and function is ReadFile from Importer

      #include <assimp/Importer.hpp>
      #include <assimp/scene.h>
      #include <assimp/postprocess.h>
      ...
      const aiScene* scene = importer.ReadFile(path,
      	aiProcess_GlobalScale |
      	aiProcess_OptimizeMeshes |
      	aiProcess_LimitBoneWeights |
      	aiProcess_JoinIdenticalVertices |
      	aiProcess_Triangulate);