/
errors.go
108 lines (90 loc) · 3 KB
/
errors.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// Copyright 2019 Keybase Inc. All rights reserved.
// Use of this source code is governed by a BSD
// license that can be found in the LICENSE file.
package idutil
import (
"fmt"
kbname "github.com/adamwalz/keybase-client/go/kbun"
"github.com/adamwalz/keybase-client/go/protocol/keybase1"
)
// NoSigChainError means that a user we were trying to identify does
// not have a sigchain.
type NoSigChainError struct {
User kbname.NormalizedUsername
}
// Error implements the error interface for NoSigChainError.
func (e NoSigChainError) Error() string {
return fmt.Sprintf("%s has not yet installed Keybase and set up the "+
"Keybase filesystem. Please ask them to.", e.User)
}
// NoCurrentSessionError indicates that the daemon has no current
// session. This is basically a wrapper for session.ErrNoSession,
// needed to give the correct return error code to the OS.
type NoCurrentSessionError struct {
}
// Error implements the error interface for NoCurrentSessionError.
func (e NoCurrentSessionError) Error() string {
return "You are not logged into Keybase. Try `keybase login`."
}
// NoSuchUserError indicates that the given user couldn't be resolved.
type NoSuchUserError struct {
Input string
}
// Error implements the error interface for NoSuchUserError
func (e NoSuchUserError) Error() string {
return fmt.Sprintf("%s is not a Keybase user", e.Input)
}
// ToStatus implements the keybase1.ToStatusAble interface for NoSuchUserError
func (e NoSuchUserError) ToStatus() keybase1.Status {
return keybase1.Status{
Name: "NotFound",
Code: int(keybase1.StatusCode_SCNotFound),
Desc: e.Error(),
}
}
// NoSuchTeamError indicates that the given team couldn't be resolved.
type NoSuchTeamError struct {
Input string
}
// Error implements the error interface for NoSuchTeamError
func (e NoSuchTeamError) Error() string {
return fmt.Sprintf("%s is not a Keybase team", e.Input)
}
// TlfNameNotCanonical indicates that a name isn't a canonical, and
// that another (not necessarily canonical) name should be tried.
type TlfNameNotCanonical struct {
Name, NameToTry string
}
// Error implements the error interface for TlfNameNotCanonical.
func (e TlfNameNotCanonical) Error() string {
return fmt.Sprintf("TLF name %s isn't canonical: try %s instead",
e.Name, e.NameToTry)
}
// NoSuchNameError indicates that the user tried to access a
// subdirectory entry that doesn't exist.
type NoSuchNameError struct {
Name string
NameToLog string
}
// Error implements the error interface for NoSuchNameError
func (e NoSuchNameError) Error() string {
n := e.Name
if len(e.NameToLog) > 0 {
n = e.NameToLog
}
return fmt.Sprintf("%s doesn't exist", n)
}
// BadTLFNameError indicates a top-level folder name that has an
// incorrect format.
type BadTLFNameError struct {
Name string
NameToLog string
}
// Error implements the error interface for BadTLFNameError.
func (e BadTLFNameError) Error() string {
n := e.Name
if len(e.NameToLog) > 0 {
n = e.NameToLog
}
return fmt.Sprintf("TLF name %s is in an incorrect format", n)
}