safe_mode

Modified on Thu, 9 Jul at 10:50 AM

safe_mode

TABLE OF CONTENTS

Guarantee execution of a line

Definition

any safe_mode(any input, &expression)

Tries to apply &expression to input. In case an error occurs, doesn't interrupt the execution of the program, but returns null instead and raises the error as a warning instead. If there is no error, returns the result of applying &expression to input.

Parameters

any input

Data to apply &expression to.

expression &expression

Expression to apply on data.

Returns

any

If applying &expression to input yields no error, returns the result. Otherwise, suppresses the error and returns null.

Examples

Transformation
{
  a: safe_mode(`[0, 1]`, divide(@[0], @[1])),
  b: safe_mode(`[0, 1]`, divide(@[1], @[0]))
}
Result
{
  "a": 0,
  "b": null    // Only a warning is raised
}

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article