I think the listener has a stream to which it prints errors but I never had to use it.
Whenever there is an error something like a SEHException is usually thrown so you can catch that. You can also check the return IValue of the script to see if it is undefined, OK, etc.