-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy patherror.go
103 lines (87 loc) · 1.92 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
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
// Copyright 2010 The go-pgsql Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package pgsql
import (
"fmt"
)
// Error contains detailed error information received from a PostgreSQL backend.
//
// Many go-pgsql functions return an os.Error value. In case of a backend error,
// a type assertion as shown below gives you a *pgsql.Error with all details:
//
// ...
// _, err := rs.FetchNext()
// if err != nil {
// if pgerr, ok := err.(*pgsql.Error); ok {
// // Do something with pgerr
// }
// }
// ...
type Error struct {
severity string
code string
message string
detail string
hint string
position string
internalPosition string
internalQuery string
where string
file string
line string
routine string
}
func (e *Error) Severity() string {
return e.severity
}
func (e *Error) Code() string {
return e.code
}
func (e *Error) Message() string {
return e.message
}
func (e *Error) Detail() string {
return e.detail
}
func (e *Error) Hint() string {
return e.hint
}
func (e *Error) Position() string {
return e.position
}
func (e *Error) InternalPosition() string {
return e.internalPosition
}
func (e *Error) InternalQuery() string {
return e.internalQuery
}
func (e *Error) Where() string {
return e.where
}
func (e *Error) File() string {
return e.file
}
func (e *Error) Line() string {
return e.line
}
func (e *Error) Routine() string {
return e.routine
}
func (e *Error) Error() string {
return fmt.Sprintf(
`Severity: %s
Code: %s
Message: %s
Detail: %s
Hint: %s
Position: %s
Internal Position: %s
Internal Query: %s
Where: %s
File: %s
Line: %s
Routine: %s`,
e.severity, e.code, e.message, e.detail, e.hint, e.position,
e.internalPosition, e.internalQuery, e.where, e.file, e.line, e.routine)
}