Add handler for 'error' event