ToolJet/docs/versioned_docs/version-2.33.0/how-to/intentionally-fail-js-query.md
Aman Regu 72fa067550
[docs]: Update formatting for How To section (#9169)
* Updated the formatting of how to docs for the next and current versions

* Used the title cases in the heading

* Updated the formatting of how to docs for the next and current versions

* Used the title cases in the heading

* updated the formatting of inspector, form, cell colors

* resolved conflicts

* Updated the formatting of bulk update multiple rows, conditionaly format table, delete multiple rows, serverside pagination

* Updated access user groups, import external lib in js and python, use axios

* fix: border colour, blur

* Revert changes to versions.json

* Changed the formatting of how to docs

* add changes from docs/next to v2.34.0

* update: how to docs

* fix: image name create-new-query

* fix: image name import-successful.png

* fix: image name flatten-js

* fix: image name math-js-v2

* update: shorten page titles

---------

Co-authored-by: Asjad Ahmed Khan <iitasjad2001@gmail.com>
Co-authored-by: Karan Rathod <karan.altcampus@gmail.com>
2024-04-11 11:34:27 +05:30

1.4 KiB

id title
intentionally-fail-js-query 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.