forked from beyondstorage/go-service-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.go
58 lines (47 loc) · 1.26 KB
/
utils.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package example
import (
"github.com/beyondstorage/go-storage/v4/services"
"github.com/beyondstorage/go-storage/v4/types"
)
// Storage is the example client.
type Storage struct {
defaultPairs DefaultStoragePairs
features StorageFeatures
types.UnimplementedStorager
}
// String implements Storager.String
func (s *Storage) String() string {
panic("implement me")
}
// NewStorager will create Storager only.
func NewStorager(pairs ...types.Pair) (types.Storager, error) {
return newStorager(pairs...)
}
// newStorager will create a storage client.
func newStorager(pairs ...types.Pair) (store *Storage, err error) {
defer func() {
if err != nil {
err = services.InitError{Op: "new_storager", Type: Type, Err: formatError(err), Pairs: pairs}
}
}()
panic("implement me")
}
func (s *Storage) formatError(op string, err error, path ...string) error {
if err == nil {
return nil
}
return services.StorageError{
Op: op,
Err: formatError(err),
Storager: s,
Path: path,
}
}
// formatError converts errors returned by SDK into errors defined in go-storage and go-service-*.
// The original error SHOULD NOT be wrapped.
func formatError(err error) error {
if _, ok := err.(services.InternalError); ok {
return err
}
panic("implement me")
}