modifying outage middleware to handle database erros