Raquel Lopez Thanks Raquel, I meant to display the same error elements that are displayed if you are using custom attributes. I will have to put some code inside the "catch" to display the error prompt I guess. now I am just alerting but it doesn't seem professional.
but, one trick will be to have one element for error prompt with a dummy text block and I pass the message string to replace the dummy text. this will be a dynamic error messaging I guess.
Yes, like you said. Inside the catch you handle the logic you prefer, for example put error.message inside a dom element like a toast or an error alert component
Comments
4 comments
You can use try catch blocks to handle errors using Javascript like this https://javascript.info/try-catch
Keep in mind that you can ask chatGPT to ask about JS technical questions and help you out with small scripts
Raquel Lopez Thanks Raquel, I meant to display the same error elements that are displayed if you are using custom attributes. I will have to put some code inside the "catch" to display the error prompt I guess. now I am just alerting but it doesn't seem professional.
but, one trick will be to have one element for error prompt with a dummy text block and I pass the message string to replace the dummy text. this will be a dynamic error messaging I guess.
Yes, like you said. Inside the catch you handle the logic you prefer, for example put error.message inside a dom element like a toast or an error alert component
Yes thanks for your help 🙏
Please sign in to leave a comment.