User Tools

Site Tools


syntax:functions:iferror

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
syntax:functions:iferror [2016/06/08 00:04] dmitrysyntax:functions:iferror [2021/08/16 03:14] craigt
Line 1: Line 1:
 ====== IfError(expression1, expression2) ====== ====== IfError(expression1, expression2) ======
 +Category:  Logical function
  
-Returns the result of //expression2// if the result of //expression1// is error. Otherwise returns the result of //expression1//+\\  
 +=====Description===== 
 +This function returns the result of //expression2// if the result of //expression1// is an error.  Otherwise, it returns the result of //expression1//.
  
 +\\ 
 +=====Use cases=====
 +This function can be used as an error handler in cases where an expression could potentially return an error.  In such a case, the return value from //expression2// acts as a "safety net" so the process can continue.
  
- Expression   Result  +\\  
-IfError( 1 / 0, 'Eternity' ) | Eternity| +=====Arguments===== 
-| IfError( 1 + 0, 'Eternity' ) 1|+^Argument^Type^Description
 +|expression1|Expression|Any expression that could potentially result in an error.| 
 +|expression2|Expression|Any expression.| 
 +**Return value type:** Any (the data type of the return value of //expression1// or //expression2//
 + 
 +\\  
 +=====Remarks===== 
 +If both //expression1// and //expression2// return errors, the error message from //expression2// is returned. 
 + 
 +\\  
 +=====Examples===== 
 + 
 +  iferror( 1/0, 'Inifity' ) //Returns 'Infinity' 
 + 
 +  iferror( 1+0, 'Infinity' ) //Returns 1 
 + 
 +  iferror( 1/0, sqrt('the') ) //Returns '#The argument must be a positive number' (the error from expression2) 
 + 
 +\\  
 +===== See also ===== 
 +  * [[syntax:functions:ifempty|IfEmpty(expression1, expression2)]] 
 +  * [[syntax:functions:iserror|IsError(expression)]]
  
-**See also** 
-  * [[syntax:functions:iserror]] 
-  * [[syntax:functions:ifempty]] 
syntax/functions/iferror.txt · Last modified: 2021/08/16 03:15 by craigt

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki