gin error handler

This commit is contained in:
2026-01-23 21:33:36 -07:00
parent b9464adada
commit 3fd533091c
5 changed files with 47 additions and 25 deletions
+4 -4
View File
@@ -212,7 +212,7 @@ func (a *Auth) AuthenticateAndAddIdentityToRequestGin(assertions ...Authorizatio
if errors.Is(err, consts.ErrNotFound) {
u, err := a.newLoginURL(ctx, a.auth, r.URL.String())
if err != nil {
response.WriteError(c, response.Errorf("failed to generate login url: %w", err))
c.Error(response.Errorf("failed to generate login url: %w", err))
c.Abort()
return
}
@@ -222,7 +222,7 @@ func (a *Auth) AuthenticateAndAddIdentityToRequestGin(assertions ...Authorizatio
return
}
response.WriteError(c, response.Errorf("failed to authenticate: %w", err))
c.Error(response.Errorf("failed to authenticate: %w", err))
c.Abort()
return
}
@@ -255,7 +255,7 @@ func (a *Auth) AuthenticateAndAddIdentityToRequestGin(assertions ...Authorizatio
user, acct, err := a.accts.GetUserAndAccountByAccessToken(ctx, accessToken)
if err != nil {
response.WriteError(c, response.Errorf("failed to authorize: %w", err))
c.Error(response.Errorf("failed to authorize: %w", err))
c.Abort()
return
}
@@ -263,7 +263,7 @@ func (a *Auth) AuthenticateAndAddIdentityToRequestGin(assertions ...Authorizatio
for _, as := range assertions {
res, err := as(c)
if err != nil {
response.WriteError(c, err)
c.Error(err)
c.Abort()
return
}