For my grammar in ANTLR, my java code can catch and print errors for inputs containing \"$\". In my implementation, I need to print out \"success\" for successful input. So,
Possibly the lexer (or parser) tries to recover from (minor) errors and continues tokenizing or parsing. If you want to terminate whenever some illegal character occurs, the easiest is to create some sort of "fall-through" rule that is placed at the end of all your lexer rules which will match if none of the lexer rules above have matched, and let that rule throw an exception:
grammar T;
// parser rules
// lexer rules
/* last lexer rules */
FALL_THROUGH
: . {throw new RuntimeException("Illegal character: " + getText());}
;