Root > Reference > All Functions > SafeExec

Procedure SafeExec

Previous pageReturn to chapter overviewNext page   

Executes routine with exception handling. Any exception is handled as fatal exception.

 

Unit

ELowLevel

 

Syntax

 

Code (Delphi)

procedure SafeExec(

const AProc: ETypes.TProcedure;

const ASection: String

);

 

Parameters

AProc [in]

A procedure to execute.

 

Must not throw exceptions as normal operation. Any exception inside this procedure is considered as fatal.

 

ASection [in]

Fully qualified name of procedure. Must have form 'UnitName.ProcName'.

 

ProcName must be either 'Init' or 'Done'.

 

Remarks

This routine is used to wrap code from initialization / finalization sections for safe executing.

 

Passed procedure is either Init or Done procedures, which performs code which should be in initialization and finalization sections. See examples for exact pattern of usage.

 

Any exception inside specified procedure is considered as fatal exception and triggers an internal EurekaLog's error.

 

Note

The names of routines ('Init' and 'Done') are important, because this procedure also changes IntoInitialization and IntoFinalization variables.

 

Any exception inside this procedure is handled by _InitDoneErrorHandler (if assigned).

 

Examples

 

Code (Delphi)

unit ESomeUnit;

// ...

implementation

// ...

procedure Init;

begin

// ...

end;

procedure Done;

begin

// ...

end;

initialization

SafeExec(Init, 'ESomeUnit.Init');

finalization

SafeExec(Done, 'ESomeUnit.Done');

end.

 

Warning

Any EurekaLog's unit must follow this pattern above (except those which do not have init/done code).

 

Important!

You must follow this pattern exactly.

 

No other code allowed in initialization / finalization section.

 

No other names allowed for Init / Done procedures.

 

See also

_InitDoneErrorHandler
ShowInternalErrorMessage



Send feedback... Build date: 2024-09-30
Last edited: 2024-09-30
PRIVACY STATEMENT
The documentation team uses the feedback submitted to improve the EurekaLog documentation. We do not use your e-mail address for any other purpose. We will remove your e-mail address from our system after the issue you are reporting has been resolved. While we are working to resolve this issue, we may send you an e-mail message to request more information about your feedback. After the issues have been addressed, we may send you an email message to let you know that your feedback has been addressed.


Permanent link to this article: https://www.eurekalog.com/help/eurekalog/topic_function_elowlevel_safeexec.php