create-go-app / fiber-go-template

📝 Production-ready backend template with Fiber Go Web Framework for Create Go App CLI.
https://github.com/create-go-app/cli/wiki
Apache License 2.0
955 stars 120 forks source link

errSaveToRedis Causes Panic #126

Closed RafaelPiloto10 closed 2 years ago

RafaelPiloto10 commented 2 years ago

Required check list:

My environment:

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(),
  })
}
welcome[bot] commented 2 years ago

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

koddr commented 2 years ago

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 ❤️

RafaelPiloto10 commented 2 years ago

No worries! I can certainly submit a PR!