CoffeeScript version of the onError handler