Skip to content

Commit b06e1c9

Browse files
committed
Fix error code in example
1 parent a4b1c6a commit b06e1c9

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

examples/storage/storage_user.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
package storage
22

33
import (
4+
"errors"
45
"fmt"
6+
"net/http"
57

8+
"github.com/manyminds/api2go"
69
"github.com/manyminds/api2go/examples/model"
710
)
811

@@ -28,8 +31,8 @@ func (s UserStorage) GetOne(id string) (model.User, error) {
2831
if ok {
2932
return *user, nil
3033
}
31-
32-
return model.User{}, fmt.Errorf("User for id %s not found", id)
34+
errMessage := fmt.Sprintf("User for id %s not found", id)
35+
return model.User{}, api2go.NewHTTPError(errors.New(errMessage), errMessage, http.StatusNotFound)
3336
}
3437

3538
// Insert a user

0 commit comments

Comments
 (0)