I am designing the interface of a plugin system for our product. Current plugins will be written in C#, but I envisage creating at least C/C++ wrappers in the future.
I am in a quandary how to handle errors given the potential language discrepancies. Normally I use exceptions for errors, but I am assuming the exception mechanism differences across languages would make this non trivial, and some languages don't support exceptions.
If this is the case then the only other patterns I can see are:
A) Return error codes from all functions. This only allows for predefined errors. Info about adhoc/unknown errors it not possible.
B) Return bools from all functions and supply a GetLastError() type function. I'm not keen on this because of possible threading issues (another thread changes the error before it can be read).
C) Return bools from all functions and have the API provide a LogError() function that the plugin can use to record any problems. Not keen on this either due to difficulty in programatically reacting to specific errors at the time of call.
D) Pass in an error info object to every function call that can be filled in. Urgh.
Is there any kind of best practice that has evolved for cross language APIs?