Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove public error AlreadyExistsError from SDKs #1468

Merged
merged 1 commit into from
Nov 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions sdk/process/process.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package processesdk

import (
"fmt"
"errors"

"github.com/mesg-foundation/engine/database"
"github.com/mesg-foundation/engine/hash"
Expand Down Expand Up @@ -46,7 +46,7 @@ func (w *Process) Create(wf *process.Process) (*process.Process, error) {

// check if process already exists.
if _, err := w.processDB.Get(wf.Hash); err == nil {
return nil, &AlreadyExistsError{Hash: wf.Hash}
return nil, errors.New("process %q already exists" + wf.Hash.String())
}

if err := wf.Validate(); err != nil {
Expand All @@ -69,12 +69,3 @@ func (w *Process) Get(hash hash.Hash) (*process.Process, error) {
func (w *Process) List() ([]*process.Process, error) {
return w.processDB.All()
}

// AlreadyExistsError is an not found error.
type AlreadyExistsError struct {
Hash hash.Hash
}

func (e *AlreadyExistsError) Error() string {
return fmt.Sprintf("process %q already exists", e.Hash.String())
}
2 changes: 1 addition & 1 deletion sdk/service/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func create(db *database.ServiceDB, req *api.CreateServiceRequest, owner cosmost

// check if service already exists.
if _, err := db.Get(srv.Hash); err == nil {
return nil, &AlreadyExistsError{Hash: srv.Hash}
return nil, errors.New("service %q already exists" + srv.Hash.String())
}

// TODO: the following test should be moved in New function
Expand Down
11 changes: 0 additions & 11 deletions sdk/service/type.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package servicesdk

import (
"fmt"

"github.com/mesg-foundation/engine/hash"
"github.com/mesg-foundation/engine/protobuf/api"
"github.com/mesg-foundation/engine/service"
Expand All @@ -16,12 +14,3 @@ type Service interface {
Exists(hash hash.Hash) (bool, error)
Hash(req *api.CreateServiceRequest) (hash.Hash, error)
}

// AlreadyExistsError is an not found error.
type AlreadyExistsError struct {
Hash hash.Hash
}

func (e *AlreadyExistsError) Error() string {
return fmt.Sprintf("service %q already exists", e.Hash.String())
}