Exceptions and DLL in Delphi

后端 未结 4 1950
心在旅途
心在旅途 2020-12-19 13:05

What is the right way to handle exceptions thrown from inside a DLL in Delphi?

Something like this

on E : ESomeException do ...

or<

4条回答
  •  不思量自难忘°
    2020-12-19 13:44

    The safest way is to not allow exceptions to "escape" from the DLL in the first place.

    But if you have no control over the source of DLL and are therefore unable to ensure this, you can still test the exception class name:

    if SameText(E.ClassName, 'ESomeException') then ...
    

提交回复
热议问题