Skip to content
This repository has been archived by the owner on Oct 25, 2023. It is now read-only.

Commit

Permalink
feat(warden): updated error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Sudheer Pal committed Oct 5, 2023
1 parent 84f99ab commit 6a235a1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions internal/server/v1/warden/handler.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package warden

import (
"errors"
"net/http"

"github.com/goto/dex/internal/server/utils"
Expand All @@ -17,11 +18,11 @@ func NewHandler(service *Service) *Handler {
func (h *Handler) teamList(w http.ResponseWriter, r *http.Request) {
teamListResp, err := h.service.TeamList(r.Context())

if err == ErrUserNotFound {
if errors.Is(err, ErrUserNotFound) {
utils.WriteErrMsg(w, http.StatusUnauthorized, ErrUserNotFound.Error())
return
}
if err == ErrTeamNotFound {
if errors.Is(err, ErrTeamNotFound) {
utils.WriteErrMsg(w, http.StatusNotFound, ErrTeamNotFound.Error())
return
}
Expand Down
2 changes: 1 addition & 1 deletion internal/server/v1/warden/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (c *Service) TeamList(ctx context.Context) (*TeamData, error) {

url := baseURL + endpoint + userPath + reqCtx.UserEmail + teamsEndpoint

resp, err := http.Get(url)
resp, err := http.Get(url) //nolint

if err != nil {
return nil, err
Expand Down

0 comments on commit 6a235a1

Please sign in to comment.