I have a third party unit, witch raises an exception in initialization section of unit. How can I catch this exception on my application?
You cannot catch such a thing. The RTL executes the initialization sections and the rules are that no exceptions are to be raised. If exceptions are raised, then the fault is terminal.
Another way to thing about this is that when the initialization sections start to be executed, the language exception handling framework is not yet in place. That itself is installed as part of the RTL initialization.
The solution is to fix the code so that it obeys the rules. No exceptions raised in initialization sections.
Well, I suppose that you could hook the RTL code that executes initialization and perhaps replace that RTL code with exception resilient code. But what would be the point? If an initialization section raises an exception, the only sane assumption to be made is that the unit is not initialized and so not fit for use. Please don't try to bury your head in the sand and ignore the real problem. Fix the third party code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With