add middleware to generate errors in download chain