Autodesk / AutomaticComponentToolkit

A toolkit to automatically generate software components: abstract API, implementation stubs and language bindings
BSD 2-Clause "Simplified" License
39 stars 22 forks source link

Error string propagation for global methods #74

Open fsahmad opened 5 years ago

fsahmad commented 5 years ago

Currently, the error string propagation works by calling RegisterErrorMessage on the base class whenever an exception is caught on the component side, which is then propagated to the binding and wrapped into a new exception.

This doesn't work for the global (CWrapper) methods, as there is no base class instance to register the error message on.

We ran into this issue as our "application" object is created and initialized using a global CreateApp method, which was throwing a std::exception due to missing runtime libraries. I would suggest to add the same mechanism to the CWrapper class so it too can propagate error messages.

alexanderoster commented 4 years ago

Dear @fsahmad,

Apologies for the delayed response. We had long discussions about this, and there is really not a good way to do this in my opinion without introducing global variables in the DLL which are an absolute nightmare for other reasons.

Our personal best practice here would be that global methods are always "non-throwing", for example in your case, the CreateApp Method would not have any parameters but just give you an App Instance that then is followed up by a "Initialize" call that has a proper error management.

@martinweismann: Do you have any thoughts?

Best regards,

Alex