mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-02 22:12:30 +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 (
|
||||
_ "embed"
|
||||
"time"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/errors"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/zerrors"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -69,10 +69,10 @@ func (h *Handler) failureCount(tx *sql.Tx, f *failure) (count uint8, err error)
|
||||
f.sequence,
|
||||
)
|
||||
if err = row.Err(); err != nil {
|
||||
return 0, errors.ThrowInternal(err, "CRDB-Unnex", "unable to update failure count")
|
||||
return 0, zerrors.ThrowInternal(err, "CRDB-Unnex", "unable to update failure count")
|
||||
}
|
||||
if err = row.Scan(&count); err != nil {
|
||||
return 0, errors.ThrowInternal(err, "CRDB-RwSMV", "unable to scan count")
|
||||
return 0, zerrors.ThrowInternal(err, "CRDB-RwSMV", "unable to scan count")
|
||||
}
|
||||
return count, nil
|
||||
}
|
||||
@@ -89,7 +89,7 @@ func (h *Handler) setFailureCount(tx *sql.Tx, count uint8, f *failure) error {
|
||||
f.err.Error(),
|
||||
)
|
||||
if err != nil {
|
||||
return errors.ThrowInternal(err, "CRDB-4Ht4x", "set failure count failed")
|
||||
return zerrors.ThrowInternal(err, "CRDB-4Ht4x", "set failure count failed")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@ import (
|
||||
"github.com/jackc/pgconn"
|
||||
"github.com/zitadel/logging"
|
||||
|
||||
errs "github.com/zitadel/zitadel/internal/errors"
|
||||
"github.com/zitadel/zitadel/internal/eventstore/handler"
|
||||
"github.com/zitadel/zitadel/internal/zerrors"
|
||||
)
|
||||
|
||||
type Table struct {
|
||||
@@ -196,7 +196,7 @@ func (h *Handler) Init(ctx context.Context) error {
|
||||
}
|
||||
tx, err := h.client.BeginTx(ctx, nil)
|
||||
if err != nil {
|
||||
return errs.ThrowInternal(err, "CRDB-SAdf2", "begin failed")
|
||||
return zerrors.ThrowInternal(err, "CRDB-SAdf2", "begin failed")
|
||||
}
|
||||
for i, execute := range check.Init().Executes {
|
||||
logging.WithFields("projection", h.projection.Name(), "execute", i).Debug("executing check")
|
||||
@@ -274,7 +274,7 @@ func execNextIfExists(config execConfig, q query, opts []execOption, executeNext
|
||||
}
|
||||
|
||||
func isErrAlreadyExists(err error) bool {
|
||||
caosErr := &errs.CaosError{}
|
||||
caosErr := &zerrors.ZitadelError{}
|
||||
if !errors.As(err, &caosErr) {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/api/authz"
|
||||
errs "github.com/zitadel/zitadel/internal/errors"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/zerrors"
|
||||
)
|
||||
|
||||
type state struct {
|
||||
@@ -97,7 +97,7 @@ func (h *Handler) setState(tx *sql.Tx, updatedState *state) error {
|
||||
}
|
||||
if affected, err := res.RowsAffected(); affected == 0 {
|
||||
h.log().OnError(err).Error("unable to check if states are updated")
|
||||
return errs.ThrowInternal(err, "V2-FGEKi", "unable to update state")
|
||||
return zerrors.ThrowInternal(err, "V2-FGEKi", "unable to update state")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -111,7 +111,7 @@ func (h *Handler) lockState(tx *sql.Tx, instanceID string) error {
|
||||
return err
|
||||
}
|
||||
if affected, err := res.RowsAffected(); affected == 0 || err != nil {
|
||||
return errs.ThrowInternal(err, "V2-lpiK0", "projection already locked")
|
||||
return zerrors.ThrowInternal(err, "V2-lpiK0", "projection already locked")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
|
||||
"github.com/zitadel/zitadel/internal/api/authz"
|
||||
"github.com/zitadel/zitadel/internal/database/mock"
|
||||
errs "github.com/zitadel/zitadel/internal/errors"
|
||||
"github.com/zitadel/zitadel/internal/zerrors"
|
||||
)
|
||||
|
||||
func TestHandler_lockState(t *testing.T) {
|
||||
@@ -80,7 +80,7 @@ func TestHandler_lockState(t *testing.T) {
|
||||
instanceID: "instance",
|
||||
},
|
||||
isErr: func(t *testing.T, err error) {
|
||||
if !errors.Is(err, errs.ThrowInternal(nil, "V2-lpiK0", "")) {
|
||||
if !errors.Is(err, zerrors.ThrowInternal(nil, "V2-lpiK0", "")) {
|
||||
t.Errorf("unexpected error: want internal (V2lpiK0), got: %v", err)
|
||||
}
|
||||
},
|
||||
@@ -195,7 +195,7 @@ func TestHandler_updateLastUpdated(t *testing.T) {
|
||||
},
|
||||
},
|
||||
isErr: func(t *testing.T, err error) {
|
||||
if !errors.Is(err, errs.ThrowInternal(nil, "V2-FGEKi", "")) {
|
||||
if !errors.Is(err, zerrors.ThrowInternal(nil, "V2-FGEKi", "")) {
|
||||
t.Errorf("unexpected error, want: %v, got %v", sql.ErrTxDone, err)
|
||||
}
|
||||
},
|
||||
|
||||
@@ -3,7 +3,7 @@ package handler
|
||||
import (
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
errs "errors"
|
||||
"errors"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -11,8 +11,8 @@ import (
|
||||
"github.com/zitadel/logging"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
"github.com/zitadel/zitadel/internal/errors"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/zerrors"
|
||||
)
|
||||
|
||||
func (h *Handler) eventsToStatements(tx *sql.Tx, events []eventstore.Event, currentState *state) (statements []*Statement, err error) {
|
||||
@@ -79,9 +79,9 @@ func WithTableSuffix(name string) func(*execConfig) {
|
||||
}
|
||||
|
||||
var (
|
||||
ErrNoProjection = errs.New("no projection")
|
||||
ErrNoValues = errs.New("no values")
|
||||
ErrNoCondition = errs.New("no condition")
|
||||
ErrNoProjection = errors.New("no projection")
|
||||
ErrNoValues = errors.New("no values")
|
||||
ErrNoCondition = errors.New("no condition")
|
||||
)
|
||||
|
||||
func NewStatement(event eventstore.Event, e Exec) *Statement {
|
||||
@@ -558,7 +558,7 @@ func exec(config execConfig, q query, opts []execOption) Exec {
|
||||
|
||||
_, err = ex.Exec("SAVEPOINT stmt_exec")
|
||||
if err != nil {
|
||||
return errors.ThrowInternal(err, "CRDB-YdOXD", "create savepoint failed")
|
||||
return zerrors.ThrowInternal(err, "CRDB-YdOXD", "create savepoint failed")
|
||||
}
|
||||
defer func() {
|
||||
if err != nil {
|
||||
@@ -570,7 +570,7 @@ func exec(config execConfig, q query, opts []execOption) Exec {
|
||||
}()
|
||||
_, err = ex.Exec(q(config), config.args...)
|
||||
if err != nil {
|
||||
return errors.ThrowInternal(err, "CRDB-pKtsr", "exec failed")
|
||||
return zerrors.ThrowInternal(err, "CRDB-pKtsr", "exec failed")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user