Enable errname linter and fix findings (#13341)

This commit is contained in:
Justin Traglia
2023-12-14 21:26:48 -06:00
committed by GitHub
parent 0fde4a22e1
commit 4a374435c0
45 changed files with 205 additions and 204 deletions

View File

@@ -5,7 +5,7 @@ import (
)
func HandleError(w http.ResponseWriter, message string, code int) {
errJson := &DefaultErrorJson{
errJson := &DefaultJsonError{
Message: message,
Code: code,
}

View File

@@ -16,17 +16,17 @@ type HasStatusCode interface {
StatusCode() int
}
// DefaultErrorJson is a JSON representation of a simple error value, containing only a message and an error code.
type DefaultErrorJson struct {
// DefaultJsonError is a JSON representation of a simple error value, containing only a message and an error code.
type DefaultJsonError struct {
Message string `json:"message"`
Code int `json:"code"`
}
func (e *DefaultErrorJson) StatusCode() int {
func (e *DefaultJsonError) StatusCode() int {
return e.Code
}
func (e *DefaultErrorJson) Error() string {
func (e *DefaultJsonError) Error() string {
return fmt.Sprintf("HTTP request unsuccessful (%d: %s)", e.Code, e.Message)
}