mirror of
https://github.com/andwati/zitadel.git
synced 2026-10-26 17:22:15 +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 <[email protected]>
This commit is contained in:
co-authored by
Elio Bischof
parent
ddbea119f1
commit
f680dd934d
Vendored
+8
-7
@@ -7,7 +7,8 @@ import (
|
||||
|
||||
a_cache "github.com/allegro/bigcache"
|
||||
"github.com/zitadel/logging"
|
||||
"github.com/zitadel/zitadel/internal/errors"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/zerrors"
|
||||
)
|
||||
|
||||
type Bigcache struct {
|
||||
@@ -29,27 +30,27 @@ func NewBigcache(c *Config) (*Bigcache, error) {
|
||||
|
||||
func (c *Bigcache) Set(key string, object interface{}) error {
|
||||
if key == "" || reflect.ValueOf(object).IsNil() {
|
||||
return errors.ThrowInvalidArgument(nil, "BIGCA-du73s", "key or value should not be empty")
|
||||
return zerrors.ThrowInvalidArgument(nil, "BIGCA-du73s", "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, "BIGCA-RUyxI", "unable to encode object")
|
||||
return zerrors.ThrowInvalidArgument(err, "BIGCA-RUyxI", "unable to encode object")
|
||||
}
|
||||
return c.cache.Set(key, b.Bytes())
|
||||
}
|
||||
|
||||
func (c *Bigcache) Get(key string, ptrToObject interface{}) error {
|
||||
if key == "" || reflect.ValueOf(ptrToObject).IsNil() {
|
||||
return errors.ThrowInvalidArgument(nil, "BIGCA-dksoe", "key or value should not be empty")
|
||||
return zerrors.ThrowInvalidArgument(nil, "BIGCA-dksoe", "key or value should not be empty")
|
||||
}
|
||||
value, err := c.cache.Get(key)
|
||||
if err == a_cache.ErrEntryNotFound {
|
||||
return errors.ThrowNotFound(err, "BIGCA-we32s", "not in cache")
|
||||
return zerrors.ThrowNotFound(err, "BIGCA-we32s", "not in cache")
|
||||
}
|
||||
if err != nil {
|
||||
logging.Log("BIGCA-ftofbc").WithError(err).Info("read from cache failed")
|
||||
return errors.ThrowInvalidArgument(err, "BIGCA-3idls", "error in reading from cache")
|
||||
return zerrors.ThrowInvalidArgument(err, "BIGCA-3idls", "error in reading from cache")
|
||||
}
|
||||
|
||||
b := bytes.NewBuffer(value)
|
||||
@@ -60,7 +61,7 @@ func (c *Bigcache) Get(key string, ptrToObject interface{}) error {
|
||||
|
||||
func (c *Bigcache) Delete(key string) error {
|
||||
if key == "" {
|
||||
return errors.ThrowInvalidArgument(nil, "BIGCA-clsi2", "key should not be empty")
|
||||
return zerrors.ThrowInvalidArgument(nil, "BIGCA-clsi2", "key should not be empty")
|
||||
}
|
||||
return c.cache.Delete(key)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user