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 <[email protected]>
This commit is contained in:
Tim Möhlmann
2023-12-08 15:30:55 +01:00
committed by GitHub
co-authored by Elio Bischof
parent ddbea119f1
commit f680dd934d
798 changed files with 5809 additions and 5813 deletions
+7 -7
View File
@@ -5,9 +5,9 @@ import (
"encoding/gob"
"reflect"
"github.com/zitadel/zitadel/internal/errors"
"github.com/VictoriaMetrics/fastcache"
"github.com/zitadel/zitadel/internal/zerrors"
)
type Fastcache struct {
@@ -22,12 +22,12 @@ func NewFastcache(config *Config) (*Fastcache, error) {
func (fc *Fastcache) Set(key string, object interface{}) error {
if key == "" || reflect.ValueOf(object).IsNil() {
return errors.ThrowInvalidArgument(nil, "FASTC-87dj3", "key or value should not be empty")
return zerrors.ThrowInvalidArgument(nil, "FASTC-87dj3", "key or value should not be empty")
}
var b bytes.Buffer
enc := gob.NewEncoder(&b)
if err := enc.Encode(object); err != nil {
return errors.ThrowInvalidArgument(err, "FASTC-RUyxI", "unable to encode object")
return zerrors.ThrowInvalidArgument(err, "FASTC-RUyxI", "unable to encode object")
}
fc.cache.Set([]byte(key), b.Bytes())
return nil
@@ -35,11 +35,11 @@ func (fc *Fastcache) Set(key string, object interface{}) error {
func (fc *Fastcache) Get(key string, ptrToObject interface{}) error {
if key == "" || reflect.ValueOf(ptrToObject).IsNil() {
return errors.ThrowInvalidArgument(nil, "FASTC-di8es", "key or value should not be empty")
return zerrors.ThrowInvalidArgument(nil, "FASTC-di8es", "key or value should not be empty")
}
data := fc.cache.Get(nil, []byte(key))
if len(data) == 0 {
return errors.ThrowNotFound(nil, "FASTC-xYzSm", "key not found")
return zerrors.ThrowNotFound(nil, "FASTC-xYzSm", "key not found")
}
b := bytes.NewBuffer(data)
@@ -50,7 +50,7 @@ func (fc *Fastcache) Get(key string, ptrToObject interface{}) error {
func (fc *Fastcache) Delete(key string) error {
if key == "" {
return errors.ThrowInvalidArgument(nil, "FASTC-lod92", "key should not be empty")
return zerrors.ThrowInvalidArgument(nil, "FASTC-lod92", "key should not be empty")
}
fc.cache.Del([]byte(key))
return nil