check for null before using app.res.logger.error