-
Notifications
You must be signed in to change notification settings - Fork 24
/
errors.go
79 lines (65 loc) · 1.24 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
/*
*/
package goh
import (
"bytes"
"github.com/sdming/goh/Hbase"
)
/*
HbaseError
*/
type HbaseError struct {
IOErr *Hbase.IOError // IOError
ArgErr *Hbase.IllegalArgument // IllegalArgument
Err error // error
}
func newHbaseError(io *Hbase.IOError, arg *Hbase.IllegalArgument, err error) *HbaseError {
return &HbaseError{
IOErr: io,
ArgErr: arg,
Err: err,
}
}
/*
String
*/
func (e *HbaseError) String() string {
if e == nil {
return "<nil>"
}
var b bytes.Buffer
if e.IOErr != nil {
b.WriteString("IOError:")
b.WriteString(e.IOErr.Message)
b.WriteString(";")
}
if e.ArgErr != nil {
b.WriteString("ArgumentError:")
b.WriteString(e.ArgErr.Message)
b.WriteString(";")
}
if e.Err != nil {
b.WriteString("Error:")
b.WriteString(e.Err.Error())
b.WriteString(";")
}
return b.String()
}
/*
Error
*/
func (e *HbaseError) Error() string {
return e.String()
}
func checkHbaseError(io *Hbase.IOError, err error) error {
if io != nil || err != nil {
return newHbaseError(io, nil, err)
}
return nil
}
func checkHbaseArgError(io *Hbase.IOError, arg *Hbase.IllegalArgument, err error) error {
if io != nil || arg != nil || err != nil {
return newHbaseError(io, arg, err)
}
return nil
}