In ToolJet, Run JavaScript (RunJS) queries can be intentionally failed to simulate error scenarios, validate application error handling, and debug query execution flows. This document explains how to **intentionally fail a RunJS** query, by also using custom logs to gain better visibility into query execution using the Debugger panel.
### Failing a RunJS Query Using JavaScript Errors
A RunJS query can be intentionally failed by throwing a JavaScript error. When an error is thrown:
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.
### Example Query
The below example demonstrates how intentional failures can be combined with custom logs to trace execution flow during debugging.
```javascript
actions.logInfo("RunJS query started");
// Intentionally fail the query
throw new Error("Intentional failure for debugging");
// This line will not be executed
actions.log("RunJS query finished");
```
<detailsid="tj-dropdown">
<summary>**Response Example**</summary>
message:"Intentional failure to test debugging and error handling"
description:"Intentional failure to test debugging and error handling"