added error handler for middleware example