Mathieu Pellerin 7599d4f8d5
[expression] Add try() function to provide a way to detect and handle
expressions which can intermittently fail.
2019-02-20 06:27:43 +07:00

15 lines
693 B
Plaintext

{
"name": "try",
"type": "function",
"description": "Tries an expression and returns its value if error-free. If the expression returns an error, an alternative value will be returned when provided otherwise the function will return null.",
"arguments": [
{"arg":"expression","description":"the expression which should be run"},
{"arg":"alternative","optional":true,"description":"the result which will be returned if the expression returns an error."}
],
"examples": [
{ "expression":"try( to_int( '1' ), 0 )", "returns":"1"},
{ "expression":"try( to_int( 'a' ), 0 )", "returns":"0"},
{ "expression":"try( to_date( 'invalid_date' ) )", "returns":"NULL"}
]
}