Fixes #3 - custom onerror function