handle errors on stream