onError and errorHandler to throw and catch