forked from influxdata/influxdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
error.go
54 lines (40 loc) · 1.09 KB
/
error.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
package common
import (
"fmt"
)
const (
WrongNumberOfArguments = iota
InvalidArgument
InternalError
)
type QueryError struct {
ErrorCode int
ErrorMsg string
}
func (self *QueryError) Error() string {
return self.ErrorMsg
}
func NewQueryError(code int, msg string, args ...interface{}) *QueryError {
return &QueryError{code, fmt.Sprintf(msg, args...)}
}
type AuthenticationError string
func (self AuthenticationError) Error() string {
return string(self)
}
func NewAuthenticationError(formatStr string, args ...interface{}) AuthenticationError {
return AuthenticationError(fmt.Sprintf(formatStr, args...))
}
type AuthorizationError string
func (self AuthorizationError) Error() string {
return string(self)
}
func NewAuthorizationError(formatStr string, args ...interface{}) AuthorizationError {
return AuthorizationError(fmt.Sprintf(formatStr, args...))
}
type DatabaseExistsError string
func (self DatabaseExistsError) Error() string {
return string(self)
}
func NewDatabaseExistsError(db string) DatabaseExistsError {
return DatabaseExistsError(fmt.Sprintf("database %s exists", db))
}