Added missing onError handler.

Without this function it was impossible to catch a Parser Error.
Add a test case too