I was wondering how to handle errors inside a script that is meant to be used as a "parser". Basically I need a way to handle parsing errors.
Since the text that this script parses should be provided in the HTML, I guess throwing the error in the javascript console is not an option, right? The user of the script should not be aware of this script, he just needs to know the syntax required for a certain HTML attribute in order to change the way the element behaves. Think of it like markdown., the only difference is that my parser will not generate any html, text, etc., it just hides or shows certain input elements if they meet conditions provided in the text to be parsed.
Should I stick with a simple browser alert message?
Appending an error message in the document (near the element that contains the text to be parsed) is not really an option, because the point of this script is to modify behaviour of certain input elements, and not to append text or something like that. Besides, it would produce inconsistent styling..