mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 16:17:32 +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:
@@ -16,9 +16,9 @@ import (
|
||||
|
||||
"github.com/zitadel/zitadel/internal/api/authz"
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
caos_errs "github.com/zitadel/zitadel/internal/errors"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/eventstore/repository"
|
||||
"github.com/zitadel/zitadel/internal/zerrors"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -189,7 +189,7 @@ func (db *CRDB) Push(ctx context.Context, commands ...eventstore.Command) (event
|
||||
"eventType", e.Type(),
|
||||
"instanceID", e.Aggregate().InstanceID,
|
||||
).WithError(err).Debug("query failed")
|
||||
return caos_errs.ThrowInternal(err, "SQL-SBP37", "unable to create event")
|
||||
return zerrors.ThrowInternal(err, "SQL-SBP37", "unable to create event")
|
||||
}
|
||||
|
||||
uniqueConstraints = append(uniqueConstraints, command.UniqueConstraints()...)
|
||||
@@ -198,8 +198,8 @@ func (db *CRDB) Push(ctx context.Context, commands ...eventstore.Command) (event
|
||||
|
||||
return db.handleUniqueConstraints(ctx, tx, uniqueConstraints...)
|
||||
})
|
||||
if err != nil && !errors.Is(err, &caos_errs.CaosError{}) {
|
||||
err = caos_errs.ThrowInternal(err, "SQL-DjgtG", "unable to store events")
|
||||
if err != nil && !errors.Is(err, &zerrors.ZitadelError{}) {
|
||||
err = zerrors.ThrowInternal(err, "SQL-DjgtG", "unable to store events")
|
||||
}
|
||||
|
||||
return events, err
|
||||
@@ -222,10 +222,10 @@ func (db *CRDB) handleUniqueConstraints(ctx context.Context, tx *sql.Tx, uniqueC
|
||||
"unique_field", uniqueConstraint.UniqueField).WithError(err).Info("insert unique constraint failed")
|
||||
|
||||
if db.isUniqueViolationError(err) {
|
||||
return caos_errs.ThrowAlreadyExists(err, "SQL-wHcEq", uniqueConstraint.ErrorMessage)
|
||||
return zerrors.ThrowAlreadyExists(err, "SQL-wHcEq", uniqueConstraint.ErrorMessage)
|
||||
}
|
||||
|
||||
return caos_errs.ThrowInternal(err, "SQL-dM9ds", "unable to create unique constraint")
|
||||
return zerrors.ThrowInternal(err, "SQL-dM9ds", "unable to create unique constraint")
|
||||
}
|
||||
case eventstore.UniqueConstraintRemove:
|
||||
_, err := tx.ExecContext(ctx, uniqueDelete, uniqueConstraint.UniqueType, uniqueConstraint.UniqueField, authz.GetInstance(ctx).InstanceID())
|
||||
@@ -233,14 +233,14 @@ func (db *CRDB) handleUniqueConstraints(ctx context.Context, tx *sql.Tx, uniqueC
|
||||
logging.WithFields(
|
||||
"unique_type", uniqueConstraint.UniqueType,
|
||||
"unique_field", uniqueConstraint.UniqueField).WithError(err).Info("delete unique constraint failed")
|
||||
return caos_errs.ThrowInternal(err, "SQL-6n88i", "unable to remove unique constraint")
|
||||
return zerrors.ThrowInternal(err, "SQL-6n88i", "unable to remove unique constraint")
|
||||
}
|
||||
case eventstore.UniqueConstraintInstanceRemove:
|
||||
_, err := tx.ExecContext(ctx, uniqueDeleteInstance, authz.GetInstance(ctx).InstanceID())
|
||||
if err != nil {
|
||||
logging.WithFields(
|
||||
"instance_id", authz.GetInstance(ctx).InstanceID()).WithError(err).Info("delete instance unique constraints failed")
|
||||
return caos_errs.ThrowInternal(err, "SQL-6n88i", "unable to remove unique constraints of instance")
|
||||
return zerrors.ThrowInternal(err, "SQL-6n88i", "unable to remove unique constraints of instance")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user