Is it possible to have a global exception hook?

前端 未结 4 1782
南方客
南方客 2020-12-28 20:57

my code is fairly well covered with exception handling (try..except). Some exceptions are not expected to happen and some exceptions happen fairly often, which is expected a

4条回答
  •  忘掉有多难
    2020-12-28 21:20

    You can do the following:

    • preserve the value of System.RaiseExceptObjProc variable, which in normal Delphi app is pointing to SysUtils.RaiseExceptObject
    • create your own "RaiseExceptObject" proc and assign it to the RaiseExceptObjProc variable
    • in your own "RaiseExceptObject" proc you can do what you want, then call saved RaiseExceptObjProc value

    For details, see above variable and procedure declarations.

提交回复
热议问题