create-go-app/fiber-go-template

errSaveToRedis Causes Panic

RafaelPiloto10 opened this issue · 3 comments

Required check list:

  • I didn't find in the repository's issues section similar bug.
  • I understand, this is Open Source and not-for-profit product.
  • This is not about third-party project, framework, package or technology.

My environment:

  • OS (uname -a): Darwin poisson.local 21.4.0 Darwin Kernel Version 21.4.0: Fri Mar 18 00:47:26 PDT 2022; root:xnu-8020.101.4~15/RELEASE_ARM64_T8101 arm64
  • Golang (go version): go version go1.18.1 darwin/amd64

Describe the bug:

Incorrect redis error handling leads to panic when Redis Save throws error.

Steps to reproduce the behavior:

Do not install Redis and try to sign in

Expected behavior:

Error handling should catch errSaveToRedis and return error. Should look like:

// Save refresh token to Redis.
errSaveToRedis := connRedis.Set(context.Background(), userID, tokens.Refresh, 0).Err()
if errSaveToRedis != nil {
// Return status 500 and Redis connection error.
  return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{
	  "error": true,
	  "msg":   errSaveToRedis.Error(),
  })
}

Thanks for opening your first issue here! 🎉 Be sure to follow the issue template!

koddr commented

Hi,

At the moment, unfortunately, I cannot fully support this project, so any help in the development of the project will be met with great gratitude!

If you have time to send a PR, then I will be happy to consider and accept it.

Thank you for your interest in the project ❤️

No worries! I can certainly submit a PR!