Skip to content

Error return value of (*github.com/gofiber/fiber/v2.Ctx).JSON is not checked (errcheck) #2376

Closed Answered by ldez
raliqala asked this question in Q&A
Discussion options

You must be logged in to vote

Hi,

You have 3 solutions:

  1. explicitly ignore the error
_ = c.Status(fiber.StatusBadRequest).JSON(fiber.Map{
	"success": false,
	"error": fiber.Map{
		"password": err.Error(),
	},
})
  1. Add an exclusion:
linters-settings:
  errcheck:
    exclude-functions:
      - (*github.com/gofiber/fiber.Ctx).JSON
  1. handle the error
err = c.Status(fiber.StatusBadRequest).JSON(fiber.Map{
	"success": false,
	"error": fiber.Map{
		"password": err.Error(),
	},
})
if err != nil {
	c.Next(err)
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@raliqala
Comment options

Answer selected by raliqala
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants