Error handling for streams