Moving errorHandler function to generateTokens function