Skip to content
This repository has been archived by the owner on Oct 22, 2021. It is now read-only.

Commit

Permalink
Update error handling (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
xxchan authored Jul 2, 2021
1 parent 4e4dee8 commit bf18972
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,36 @@ func (s *Storage) String() string {

// 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 (s *Storage) formatError(op string, err error, path ...string) error {
func formatError(err error) error {
if _, ok := err.(services.InternalError); ok {
return err
}
Expand Down

0 comments on commit bf18972

Please sign in to comment.