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.
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.
Schober I tried using try/catch(...)
but something happens inside the called function that breaks the program and does not exit in catch
.
What library & function is it?
If you're on Windows, you can try using Windows OS function 'SetUnhandledExceptionFilter' to catch the error.
Example: https://www.codeproject.com/articles/154686/setunhandledexceptionfilter-and-the-c-c-runtime-li
Schober 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);
© 2022 - 2024 — McMap. All rights reserved.