Generate middleware which simulates server errors