add error handler for stream pipe