Save error handler in callback function