mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 01:47:33 +00:00
refactor: rename package errors to zerrors (#7039)
* chore: rename package errors to zerrors * rename package errors to gerrors * fix error related linting issues * fix zitadel error assertion * fix gosimple linting issues * fix deprecated linting issues * resolve gci linting issues * fix import structure --------- Co-authored-by: Elio Bischof <elio@zitadel.com>
This commit is contained in:
@@ -5,8 +5,8 @@ import (
|
||||
|
||||
"github.com/zitadel/logging"
|
||||
|
||||
caos_errs "github.com/zitadel/zitadel/internal/errors"
|
||||
es_models "github.com/zitadel/zitadel/internal/eventstore/v1/models"
|
||||
"github.com/zitadel/zitadel/internal/zerrors"
|
||||
)
|
||||
|
||||
type Address struct {
|
||||
@@ -50,7 +50,7 @@ func (a *Address) setData(event *es_models.Event) error {
|
||||
a.ObjectRoot.AppendEvent(event)
|
||||
if err := json.Unmarshal(event.Data, a); err != nil {
|
||||
logging.Log("EVEN-clos0").WithError(err).Error("could not unmarshal event data")
|
||||
return caos_errs.ThrowInternal(err, "MODEL-so92s", "could not unmarshal event")
|
||||
return zerrors.ThrowInternal(err, "MODEL-so92s", "could not unmarshal event")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@@ -5,8 +5,8 @@ import (
|
||||
|
||||
"github.com/zitadel/logging"
|
||||
|
||||
caos_errs "github.com/zitadel/zitadel/internal/errors"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/zerrors"
|
||||
)
|
||||
|
||||
type AuthRequest struct {
|
||||
@@ -25,7 +25,7 @@ type BrowserInfo struct {
|
||||
func (a *AuthRequest) SetData(event eventstore.Event) error {
|
||||
if err := event.Unmarshal(a); err != nil {
|
||||
logging.Log("EVEN-T5df6").WithError(err).Error("could not unmarshal event data")
|
||||
return caos_errs.ThrowInternal(err, "MODEL-yGmhh", "could not unmarshal event")
|
||||
return zerrors.ThrowInternal(err, "MODEL-yGmhh", "could not unmarshal event")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@@ -7,8 +7,8 @@ import (
|
||||
"github.com/zitadel/logging"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/crypto"
|
||||
caos_errs "github.com/zitadel/zitadel/internal/errors"
|
||||
es_models "github.com/zitadel/zitadel/internal/eventstore/v1/models"
|
||||
"github.com/zitadel/zitadel/internal/zerrors"
|
||||
)
|
||||
|
||||
type Email struct {
|
||||
@@ -51,7 +51,7 @@ func (a *Email) setData(event *es_models.Event) error {
|
||||
a.ObjectRoot.AppendEvent(event)
|
||||
if err := json.Unmarshal(event.Data, a); err != nil {
|
||||
logging.Log("EVEN-dlo9s").WithError(err).Error("could not unmarshal event data")
|
||||
return caos_errs.ThrowInternal(err, "MODEL-sl9xw", "could not unmarshal event")
|
||||
return zerrors.ThrowInternal(err, "MODEL-sl9xw", "could not unmarshal event")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -61,7 +61,7 @@ func (a *EmailCode) SetData(event *es_models.Event) error {
|
||||
a.CreationDate = event.CreationDate
|
||||
if err := json.Unmarshal(event.Data, a); err != nil {
|
||||
logging.Log("EVEN-lo9s").WithError(err).Error("could not unmarshal event data")
|
||||
return caos_errs.ThrowInternal(err, "MODEL-s8uws", "could not unmarshal event")
|
||||
return zerrors.ThrowInternal(err, "MODEL-s8uws", "could not unmarshal event")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@@ -5,8 +5,8 @@ import (
|
||||
|
||||
"github.com/zitadel/logging"
|
||||
|
||||
caos_errs "github.com/zitadel/zitadel/internal/errors"
|
||||
es_models "github.com/zitadel/zitadel/internal/eventstore/v1/models"
|
||||
"github.com/zitadel/zitadel/internal/zerrors"
|
||||
)
|
||||
|
||||
type ExternalIDP struct {
|
||||
@@ -54,7 +54,7 @@ func (pw *ExternalIDP) setData(event *es_models.Event) error {
|
||||
pw.ObjectRoot.AppendEvent(event)
|
||||
if err := json.Unmarshal(event.Data, pw); err != nil {
|
||||
logging.Log("EVEN-Msi9d").WithError(err).Error("could not unmarshal event data")
|
||||
return caos_errs.ThrowInternal(err, "MODEL-A9osf", "could not unmarshal event")
|
||||
return zerrors.ThrowInternal(err, "MODEL-A9osf", "could not unmarshal event")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@@ -4,10 +4,10 @@ import (
|
||||
"github.com/zitadel/logging"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/crypto"
|
||||
caos_errs "github.com/zitadel/zitadel/internal/errors"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
es_models "github.com/zitadel/zitadel/internal/eventstore/v1/models"
|
||||
"github.com/zitadel/zitadel/internal/user/model"
|
||||
"github.com/zitadel/zitadel/internal/zerrors"
|
||||
)
|
||||
|
||||
type OTP struct {
|
||||
@@ -40,7 +40,7 @@ func (o *OTP) setData(event eventstore.Event) error {
|
||||
o.ObjectRoot.AppendEvent(event)
|
||||
if err := event.Unmarshal(o); err != nil {
|
||||
logging.Log("EVEN-d9soe").WithError(err).Error("could not unmarshal event data")
|
||||
return caos_errs.ThrowInternal(err, "MODEL-lo023", "could not unmarshal event")
|
||||
return zerrors.ThrowInternal(err, "MODEL-lo023", "could not unmarshal event")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -48,7 +48,7 @@ func (o *OTP) setData(event eventstore.Event) error {
|
||||
func (o *OTPVerified) SetData(event eventstore.Event) error {
|
||||
if err := event.Unmarshal(o); err != nil {
|
||||
logging.Log("EVEN-BF421").WithError(err).Error("could not unmarshal event data")
|
||||
return caos_errs.ThrowInternal(err, "MODEL-GB6hj", "could not unmarshal event")
|
||||
return zerrors.ThrowInternal(err, "MODEL-GB6hj", "could not unmarshal event")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@@ -6,9 +6,9 @@ import (
|
||||
"github.com/zitadel/logging"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/crypto"
|
||||
caos_errs "github.com/zitadel/zitadel/internal/errors"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
es_models "github.com/zitadel/zitadel/internal/eventstore/v1/models"
|
||||
"github.com/zitadel/zitadel/internal/zerrors"
|
||||
)
|
||||
|
||||
type Password struct {
|
||||
@@ -51,7 +51,7 @@ func (pw *Password) setData(event eventstore.Event) error {
|
||||
pw.ObjectRoot.AppendEvent(event)
|
||||
if err := event.Unmarshal(pw); err != nil {
|
||||
logging.Log("EVEN-dks93").WithError(err).Error("could not unmarshal event data")
|
||||
return caos_errs.ThrowInternal(err, "MODEL-sl9xlo2rsw", "could not unmarshal event")
|
||||
return zerrors.ThrowInternal(err, "MODEL-sl9xlo2rsw", "could not unmarshal event")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -61,7 +61,7 @@ func (c *PasswordCode) SetData(event eventstore.Event) error {
|
||||
c.CreationDate = event.CreatedAt()
|
||||
if err := event.Unmarshal(c); err != nil {
|
||||
logging.Log("EVEN-lo0y2").WithError(err).Error("could not unmarshal event data")
|
||||
return caos_errs.ThrowInternal(err, "MODEL-q21dr", "could not unmarshal event")
|
||||
return zerrors.ThrowInternal(err, "MODEL-q21dr", "could not unmarshal event")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -69,7 +69,7 @@ func (c *PasswordCode) SetData(event eventstore.Event) error {
|
||||
func (pw *PasswordChange) SetData(event eventstore.Event) error {
|
||||
if err := event.Unmarshal(pw); err != nil {
|
||||
logging.Log("EVEN-ADs31").WithError(err).Error("could not unmarshal event data")
|
||||
return caos_errs.ThrowInternal(err, "MODEL-BDd32", "could not unmarshal event")
|
||||
return zerrors.ThrowInternal(err, "MODEL-BDd32", "could not unmarshal event")
|
||||
}
|
||||
pw.ObjectRoot.AppendEvent(event)
|
||||
return nil
|
||||
|
@@ -7,8 +7,8 @@ import (
|
||||
"github.com/zitadel/logging"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/crypto"
|
||||
caos_errs "github.com/zitadel/zitadel/internal/errors"
|
||||
es_models "github.com/zitadel/zitadel/internal/eventstore/v1/models"
|
||||
"github.com/zitadel/zitadel/internal/zerrors"
|
||||
)
|
||||
|
||||
type Phone struct {
|
||||
@@ -56,7 +56,7 @@ func (p *Phone) setData(event *es_models.Event) error {
|
||||
p.ObjectRoot.AppendEvent(event)
|
||||
if err := json.Unmarshal(event.Data, p); err != nil {
|
||||
logging.Log("EVEN-lco9s").WithError(err).Error("could not unmarshal event data")
|
||||
return caos_errs.ThrowInternal(err, "MODEL-lre56", "could not unmarshal event")
|
||||
return zerrors.ThrowInternal(err, "MODEL-lre56", "could not unmarshal event")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -66,7 +66,7 @@ func (c *PhoneCode) SetData(event *es_models.Event) error {
|
||||
c.CreationDate = event.CreationDate
|
||||
if err := json.Unmarshal(event.Data, c); err != nil {
|
||||
logging.Log("EVEN-sk8ws").WithError(err).Error("could not unmarshal event data")
|
||||
return caos_errs.ThrowInternal(err, "MODEL-7hdj3", "could not unmarshal event")
|
||||
return zerrors.ThrowInternal(err, "MODEL-7hdj3", "could not unmarshal event")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@@ -7,9 +7,9 @@ import (
|
||||
"github.com/zitadel/logging"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
caos_errs "github.com/zitadel/zitadel/internal/errors"
|
||||
es_models "github.com/zitadel/zitadel/internal/eventstore/v1/models"
|
||||
user_repo "github.com/zitadel/zitadel/internal/repository/user"
|
||||
"github.com/zitadel/zitadel/internal/zerrors"
|
||||
)
|
||||
|
||||
type Token struct {
|
||||
@@ -49,7 +49,7 @@ func (t *Token) setData(event *es_models.Event) error {
|
||||
t.ObjectRoot.AppendEvent(event)
|
||||
if err := json.Unmarshal(event.Data, t); err != nil {
|
||||
logging.Log("EVEN-4Fm9s").WithError(err).Error("could not unmarshal event data")
|
||||
return caos_errs.ThrowInternal(err, "MODEL-5Gms9", "could not unmarshal event")
|
||||
return zerrors.ThrowInternal(err, "MODEL-5Gms9", "could not unmarshal event")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@@ -6,11 +6,10 @@ import (
|
||||
|
||||
"github.com/zitadel/logging"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/errors"
|
||||
caos_errs "github.com/zitadel/zitadel/internal/errors"
|
||||
es_models "github.com/zitadel/zitadel/internal/eventstore/v1/models"
|
||||
"github.com/zitadel/zitadel/internal/repository/user"
|
||||
"github.com/zitadel/zitadel/internal/user/model"
|
||||
"github.com/zitadel/zitadel/internal/zerrors"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -80,13 +79,13 @@ func (u *User) AppendEvent(event *es_models.Event) error {
|
||||
return u.Machine.AppendEvent(event)
|
||||
}
|
||||
|
||||
return errors.ThrowNotFound(nil, "MODEL-x9TaX", "Errors.UserType.Undefined")
|
||||
return zerrors.ThrowNotFound(nil, "MODEL-x9TaX", "Errors.UserType.Undefined")
|
||||
}
|
||||
|
||||
func (u *User) setData(event *es_models.Event) error {
|
||||
if err := json.Unmarshal(event.Data, u); err != nil {
|
||||
logging.Log("EVEN-ZDzQy").WithError(err).Error("could not unmarshal event data")
|
||||
return caos_errs.ThrowInternal(err, "MODEL-yGmhh", "could not unmarshal event")
|
||||
return zerrors.ThrowInternal(err, "MODEL-yGmhh", "could not unmarshal event")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@@ -7,10 +7,10 @@ import (
|
||||
"github.com/zitadel/logging"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/crypto"
|
||||
caos_errs "github.com/zitadel/zitadel/internal/errors"
|
||||
es_models "github.com/zitadel/zitadel/internal/eventstore/v1/models"
|
||||
"github.com/zitadel/zitadel/internal/repository/user"
|
||||
"github.com/zitadel/zitadel/internal/user/model"
|
||||
"github.com/zitadel/zitadel/internal/zerrors"
|
||||
)
|
||||
|
||||
type Human struct {
|
||||
@@ -159,7 +159,7 @@ func (h *Human) ComputeObject() {
|
||||
func (u *Human) setData(event *es_models.Event) error {
|
||||
if err := json.Unmarshal(event.Data, u); err != nil {
|
||||
logging.Log("EVEN-8ujgd").WithError(err).Error("could not unmarshal event data")
|
||||
return caos_errs.ThrowInternal(err, "MODEL-sj4jd", "could not unmarshal event")
|
||||
return zerrors.ThrowInternal(err, "MODEL-sj4jd", "could not unmarshal event")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -179,7 +179,7 @@ func (c *InitUserCode) SetData(event *es_models.Event) error {
|
||||
c.ObjectRoot.AppendEvent(event)
|
||||
if err := json.Unmarshal(event.Data, c); err != nil {
|
||||
logging.Log("EVEN-7duwe").WithError(err).Error("could not unmarshal event data")
|
||||
return caos_errs.ThrowInternal(err, "MODEL-lo34s", "could not unmarshal event")
|
||||
return zerrors.ThrowInternal(err, "MODEL-lo34s", "could not unmarshal event")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@@ -6,9 +6,9 @@ import (
|
||||
|
||||
"github.com/zitadel/logging"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/errors"
|
||||
es_models "github.com/zitadel/zitadel/internal/eventstore/v1/models"
|
||||
user_repo "github.com/zitadel/zitadel/internal/repository/user"
|
||||
"github.com/zitadel/zitadel/internal/zerrors"
|
||||
)
|
||||
|
||||
type Machine struct {
|
||||
@@ -39,7 +39,7 @@ func (sa *Machine) AppendEvent(event *es_models.Event) (err error) {
|
||||
func (sa *Machine) setData(event *es_models.Event) error {
|
||||
if err := json.Unmarshal(event.Data, sa); err != nil {
|
||||
logging.Log("EVEN-8ujgd").WithError(err).Error("could not unmarshal event data")
|
||||
return errors.ThrowInternal(err, "MODEL-GwjY9", "could not unmarshal event")
|
||||
return zerrors.ThrowInternal(err, "MODEL-GwjY9", "could not unmarshal event")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -69,7 +69,7 @@ func (key *MachineKey) AppendEvent(event *es_models.Event) (err error) {
|
||||
case user_repo.MachineKeyAddedEventType:
|
||||
err = json.Unmarshal(event.Data, key)
|
||||
if err != nil {
|
||||
return errors.ThrowInternal(err, "MODEL-SjI4S", "Errors.Internal")
|
||||
return zerrors.ThrowInternal(err, "MODEL-SjI4S", "Errors.Internal")
|
||||
}
|
||||
case user_repo.MachineKeyRemovedEventType:
|
||||
key.ExpirationDate = event.CreationDate
|
||||
|
@@ -3,10 +3,10 @@ package model
|
||||
import (
|
||||
"github.com/zitadel/logging"
|
||||
|
||||
caos_errs "github.com/zitadel/zitadel/internal/errors"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
es_models "github.com/zitadel/zitadel/internal/eventstore/v1/models"
|
||||
"github.com/zitadel/zitadel/internal/user/model"
|
||||
"github.com/zitadel/zitadel/internal/zerrors"
|
||||
)
|
||||
|
||||
type WebAuthNToken struct {
|
||||
@@ -64,7 +64,7 @@ func GetWebauthn(webauthnTokens []*WebAuthNToken, id string) (int, *WebAuthNToke
|
||||
func (w *WebAuthNVerify) SetData(event eventstore.Event) error {
|
||||
if err := event.Unmarshal(w); err != nil {
|
||||
logging.Log("EVEN-G342rf").WithError(err).Error("could not unmarshal event data")
|
||||
return caos_errs.ThrowInternal(err, "MODEL-B6641", "could not unmarshal event")
|
||||
return zerrors.ThrowInternal(err, "MODEL-B6641", "could not unmarshal event")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -101,7 +101,7 @@ func (u *Human) appendU2FVerifiedEvent(event eventstore.Event) error {
|
||||
token.State = int32(model.MFAStateReady)
|
||||
return nil
|
||||
}
|
||||
return caos_errs.ThrowPreconditionFailed(nil, "MODEL-4hu9s", "Errors.Users.MFA.U2F.NotExisting")
|
||||
return zerrors.ThrowPreconditionFailed(nil, "MODEL-4hu9s", "Errors.Users.MFA.U2F.NotExisting")
|
||||
}
|
||||
|
||||
func (u *Human) appendU2FChangeSignCountEvent(event eventstore.Event) error {
|
||||
@@ -114,7 +114,7 @@ func (u *Human) appendU2FChangeSignCountEvent(event eventstore.Event) error {
|
||||
token.setData(event)
|
||||
return nil
|
||||
}
|
||||
return caos_errs.ThrowPreconditionFailed(nil, "MODEL-5Ms8h", "Errors.Users.MFA.U2F.NotExisting")
|
||||
return zerrors.ThrowPreconditionFailed(nil, "MODEL-5Ms8h", "Errors.Users.MFA.U2F.NotExisting")
|
||||
}
|
||||
|
||||
func (u *Human) appendU2FRemovedEvent(event eventstore.Event) error {
|
||||
@@ -166,7 +166,7 @@ func (u *Human) appendPasswordlessVerifiedEvent(event eventstore.Event) error {
|
||||
token.State = int32(model.MFAStateReady)
|
||||
return nil
|
||||
}
|
||||
return caos_errs.ThrowPreconditionFailed(nil, "MODEL-mKns8", "Errors.Users.MFA.Passwordless.NotExisting")
|
||||
return zerrors.ThrowPreconditionFailed(nil, "MODEL-mKns8", "Errors.Users.MFA.Passwordless.NotExisting")
|
||||
}
|
||||
|
||||
func (u *Human) appendPasswordlessChangeSignCountEvent(event eventstore.Event) error {
|
||||
@@ -182,7 +182,7 @@ func (u *Human) appendPasswordlessChangeSignCountEvent(event eventstore.Event) e
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return caos_errs.ThrowPreconditionFailed(nil, "MODEL-2Mv9s", "Errors.Users.MFA.Passwordless.NotExisting")
|
||||
return zerrors.ThrowPreconditionFailed(nil, "MODEL-2Mv9s", "Errors.Users.MFA.Passwordless.NotExisting")
|
||||
}
|
||||
|
||||
func (u *Human) appendPasswordlessRemovedEvent(event eventstore.Event) error {
|
||||
@@ -206,7 +206,7 @@ func (w *WebAuthNToken) setData(event eventstore.Event) error {
|
||||
w.ObjectRoot.AppendEvent(event)
|
||||
if err := event.Unmarshal(w); err != nil {
|
||||
logging.Log("EVEN-4M9is").WithError(err).Error("could not unmarshal event data")
|
||||
return caos_errs.ThrowInternal(err, "MODEL-lo023", "could not unmarshal event")
|
||||
return zerrors.ThrowInternal(err, "MODEL-lo023", "could not unmarshal event")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -251,7 +251,7 @@ func (w *WebAuthNLogin) setData(event eventstore.Event) error {
|
||||
w.ObjectRoot.AppendEvent(event)
|
||||
if err := event.Unmarshal(w); err != nil {
|
||||
logging.Log("EVEN-hmSlo").WithError(err).Error("could not unmarshal event data")
|
||||
return caos_errs.ThrowInternal(err, "MODEL-lo023", "could not unmarshal event")
|
||||
return zerrors.ThrowInternal(err, "MODEL-lo023", "could not unmarshal event")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user