Issue
I am having trouble disabling the default error Toasts in Appsmith when an action fails. I want to configure my own error messages for when an action fails, but I can't find the setting to do so. I would like to disable the default error Toasts and add my own custom error message for an API call on a button.
Resolution
To disable the default error toasts in Appsmith and add your own custom error messages for failed actions, you can use an async JS function with a try/catch block. Here's an example:
async function handleButtonClick() { try { // Call your API/query here } catch (error) { console.error(error); // Show a custom error message appsmith.plugins.toast.error("Custom error message"); }}
In the try block, you can call your API or query, and in the catch block you can handle any errors that occur by logging them to the console and showing a custom error message using the appsmith.plugins.toast.error()
function. This function takes a string parameter for the error message to display.