feat(storage): remap rpc errors
arcad/edge/pipeline/head This commit looks good
Details
arcad/edge/pipeline/head This commit looks good
Details
This commit is contained in:
parent
22a3326be9
commit
6e4bf2f025
|
@ -63,7 +63,7 @@ func (s *BlobStore) OpenBucket(ctx context.Context, name string) (storage.BlobBu
|
|||
func (s *BlobStore) call(ctx context.Context, serviceMethod string, args any, reply any) error {
|
||||
err := s.withClient(ctx, func(ctx context.Context, client *rpc.Client) error {
|
||||
if err := client.Call(ctx, serviceMethod, args, reply); err != nil {
|
||||
return errors.WithStack(err)
|
||||
return errors.WithStack(remapBlobError(err))
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -96,7 +96,7 @@ func (s *DocumentStore) Upsert(ctx context.Context, collection string, doc stora
|
|||
func (s *DocumentStore) call(ctx context.Context, serviceMethod string, args any, reply any) error {
|
||||
err := s.withClient(ctx, func(ctx context.Context, client *rpc.Client) error {
|
||||
if err := client.Call(ctx, serviceMethod, args, reply); err != nil {
|
||||
return errors.WithStack(err)
|
||||
return errors.WithStack(remapDocumentError(err))
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -1,10 +1,31 @@
|
|||
package client
|
||||
|
||||
import (
|
||||
"forge.cadoles.com/arcad/edge/pkg/storage"
|
||||
"forge.cadoles.com/arcad/edge/pkg/storage/share"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func remapBlobError(err error) error {
|
||||
switch errors.Cause(err).Error() {
|
||||
case storage.ErrBlobNotFound.Error():
|
||||
return storage.ErrBlobNotFound
|
||||
case storage.ErrBucketClosed.Error():
|
||||
return storage.ErrBucketClosed
|
||||
default:
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
func remapDocumentError(err error) error {
|
||||
switch errors.Cause(err).Error() {
|
||||
case storage.ErrDocumentNotFound.Error():
|
||||
return storage.ErrDocumentNotFound
|
||||
default:
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
func remapShareError(err error) error {
|
||||
switch errors.Cause(err).Error() {
|
||||
case share.ErrAttributeRequired.Error():
|
||||
|
|
Loading…
Reference in New Issue