Workaround to "import" an exception from a DLL
frame
frame86 at live.com
Sun Mar 14 18:04:32 UTC 2021
On Sunday, 14 March 2021 at 15:45:19 UTC, Imperatorn wrote:
> On Sunday, 14 March 2021 at 09:35:40 UTC, frame wrote:
> In the past I've used a two patterns which are kinda wierd but.
> Basically the first is returning a tuple w value and exception
> and just check it, kinda like Go. The second approach is to
> have a function u can call to get the latest ex, kinda like
> GetLastError win api
I think that is like my pattern actually. I can call a method for
the latest exception. But to throw it I need to create a new
instance and copy the data.
I would like to have a proxy that can copy the data into a new
instance without manually checking for the type via string
comparison. I don't care for the call trace, this data is
collected and saved as string before the DLL function returns.
The idea is to scan the TypeInfo memory area of the exception and
replace it with the one that is valid for current context so the
object can be recognized later and set the call stack reference
or whatever the crash causes to null. Alternatively a new
instance should be created and data just copied automatically.
More information about the Digitalmars-d-learn
mailing list