As requested, if no onError then default handling

did as you said. slightly changed your code to spare me a var ;)
take care, no block declaration for var in js. scope is the whole function
Merge pull request #28 from kktos/master

As requested, if no onError then default handling