Skip to main content
Version: 3.1.0-Beta 🚧

Intentionally Throwing an Error in RunJS for Debugging

In this step-by-step guide, we'll walk you through the process of creating a RunJS query that intentionally throws an error for debugging purposes.

Creating the Error-Throwing RunJS Query

  1. Create a new RunJS query by clicking the + Add button on the query panel.

  2. Paste the following code into the RunJS query editor. This code utilizes the ReferenceError constructor to intentionally generate an error.

    throw new ReferenceError('This is a reference error.'); 

Adding an Event Handler for Failure

  1. Now, enhance the query by adding an event handler that will display an alert when the query fails.

  2. Click the "Run" button to execute the query and observe the intentional error being thrown.

Refer to the screencast below:

reate a new RunJS query

By following these steps, you can effectively simulate errors in your RunJS queries, aiding in the debugging process and improving the overall robustness of your code.