ebs.getSafe

Executes a function and returns either its return value or, in the case of an error/exception, the undefined property.

ebs.getSafe allows you to handle function errors in a way that interferes as little as possible with the rest of your code execution.

Syntax

Copy
function ebs.getSafe<T>(fn: Function): T;
 
Parameter Type Description
fn Function Name of the function to be executed.

Return Value

If the function passed as parameter executes successfully, its return value is returned. If the function passed as parameter generates an error or exception, the undefined property is returned.

Example