1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-22 04:09:04 +08:00

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>
This commit is contained in:
Brian Tiger Chow
2014-11-13 02:34:04 -08:00
committed by Juan Batiz-Benet
parent c5e75f91a6
commit ca2828f33c
2 changed files with 7 additions and 3 deletions

View File

@ -53,7 +53,7 @@ IPFS very quickly. To start, run:
t, err := tourGet(id) t, err := tourGet(id)
if err != nil { if err != nil {
return nil, err return nil, cmds.ClientError(err.Error())
} }
err = tourShow(out, t) err = tourShow(out, t)

View File

@ -65,9 +65,9 @@ type Command struct {
} }
// ErrNotCallable signals a command that cannot be called. // ErrNotCallable signals a command that cannot be called.
var ErrNotCallable = errors.New("This command can't be called directly. Try one of its subcommands.") var ErrNotCallable = ClientError("This command can't be called directly. Try one of its subcommands.")
var ErrNoFormatter = errors.New("This command cannot be formatted to plain text") var ErrNoFormatter = ClientError("This command cannot be formatted to plain text")
var ErrIncorrectType = errors.New("The command returned a value with a different type than expected") var ErrIncorrectType = errors.New("The command returned a value with a different type than expected")
@ -276,3 +276,7 @@ func checkArgValue(v interface{}, def Argument) error {
return nil return nil
} }
func ClientError(msg string) error {
return &Error{Code: ErrClient, Message: msg}
}