forked from denisenkom/go-mssqldb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
error.go
73 lines (58 loc) · 1.33 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
package mssql
import (
"fmt"
)
// Error represents an SQL Server error. This
// type includes methods for reading the contents
// of the struct, which allows calling programs
// to check for specific error conditions without
// having to import this package directly.
type Error struct {
Number int32
State uint8
Class uint8
Message string
ServerName string
ProcName string
LineNo int32
}
func (e Error) Error() string {
return "mssql: " + e.Message
}
// SQLErrorNumber returns the SQL Server error number.
func (e Error) SQLErrorNumber() int32 {
return e.Number
}
func (e Error) SQLErrorState() uint8 {
return e.State
}
func (e Error) SQLErrorClass() uint8 {
return e.Class
}
func (e Error) SQLErrorMessage() string {
return e.Message
}
func (e Error) SQLErrorServerName() string {
return e.ServerName
}
func (e Error) SQLErrorProcName() string {
return e.ProcName
}
func (e Error) SQLErrorLineNo() int32 {
return e.LineNo
}
type StreamError struct {
Message string
}
func (e StreamError) Error() string {
return e.Message
}
func streamErrorf(format string, v ...interface{}) StreamError {
return StreamError{"Invalid TDS stream: " + fmt.Sprintf(format, v...)}
}
func badStreamPanic(err error) {
panic(err)
}
func badStreamPanicf(format string, v ...interface{}) {
panic(streamErrorf(format, v...))
}