SafeCallErrorProc Variable
var SafeCallErrorProc: Pointer; procedureSafeCallError
(ErrorCode: Integer; ErrorAddr: Pointer); begin ... end; SafeCallErrorProc := @SafeCallError
;
Delphi calls the procedure that
SafeCallErrorProc
points to when a
safecall
routine returns an
HResult
that indicates an error. If
SafeCallErrorProc
is nil
, or if
the procedure does not raise an exception (so it returns normally),
Delphi reports runtime error 24
(ESafeCallException
).
The ComObj
unit sets this variable to a procedure
that tries to get IErrorInfo
information, and
raise an EOleException
exception using the
ErrorCode
and IErrorInfo
data.
When you implement a COM server in Delphi, any Delphi exceptions
raised in a safecall
method are handled by the
object’s SafeCallException
method and mapped
to an HResult
. The
SafeCallErrorProc
procedure is called only for
runtime errors and non-Delphi
exceptions.