Added register error handler