@cryptotaxi247 / kubo / commits / ca2828f33

feat(commands) add ClientError(msg) helper and use it to return a fancy error to the client in the tour

@jbenet this exists now License: MIT Signed-off-by: Brian Tiger Chow <brian@perfmode.com>

Brian Tiger Chow committed Nov 13, 2014 at 02:34 UTC ca2828f33c457fa105e890f8738049d92893bfae
2 files changed +7 -3
cmd/ipfs2/tour.go
+1 -1
@@ -53,7 +53,7 @@ IPFS very quickly. To start, run:
53
54 t, err := tourGet(id)
55 if err != nil {
56 - return nil, err
56 + return nil, cmds.ClientError(err.Error())
57 }
58
59 err = tourShow(out, t)
commands/command.go
+6 -2
@@ -65,9 +65,9 @@ type Command struct {
65 }
66
67 // ErrNotCallable signals a command that cannot be called.
68 -var ErrNotCallable = errors.New("This command can't be called directly. Try one of its subcommands.")
68 +var ErrNotCallable = ClientError("This command can't be called directly. Try one of its subcommands.")
69
70 -var ErrNoFormatter = errors.New("This command cannot be formatted to plain text")
70 +var ErrNoFormatter = ClientError("This command cannot be formatted to plain text")
71
72 var ErrIncorrectType = errors.New("The command returned a value with a different type than expected")
73
@@ -276,3 +276,7 @@ func checkArgValue(v interface{}, def Argument) error {
276
277 return nil
278 }
279 +
280 +func ClientError(msg string) error {
281 + return &Error{Code: ErrClient, Message: msg}
282 +}