From fc39c92fdbc33a0581f7b232333c81a67d31bb6d Mon Sep 17 00:00:00 2001 From: Blake Gentry Date: Sat, 15 Mar 2025 23:20:40 -0500 Subject: [PATCH] add apierror.Unauthorized --- apierror/api_error.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/apierror/api_error.go b/apierror/api_error.go index 3510419..1bfcf08 100644 --- a/apierror/api_error.go +++ b/apierror/api_error.go @@ -168,3 +168,20 @@ func NewServiceUnavailable(message string) *ServiceUnavailable { func NewServiceUnavailablef(format string, a ...any) *ServiceUnavailable { return NewServiceUnavailable(fmt.Sprintf(format, a...)) } + +// +// Unauthorized +// + +type Unauthorized struct { //nolint:errname + APIError +} + +func NewUnauthorized(format string, a ...any) *Unauthorized { + return &Unauthorized{ + APIError: APIError{ + Message: fmt.Sprintf(format, a...), + StatusCode: http.StatusUnauthorized, + }, + } +}