Adding try/except block in middleware to avoid unecessary errors