Debian Codegraph @

error.go

raw symbols SCIP
1 package mssql
2
3 import (
4 "fmt"
5 )
6
7 // Error represents an SQL Server error. This
8 // type includes methods for reading the contents
9 // of the struct, which allows calling programs
10 // to check for specific error conditions without
11 // having to import this package directly.
12 type Error struct {
13 Number int32
14 State uint8
15 Class uint8
16 Message string
17 ServerName string
18 ProcName string
19 LineNo int32
20 }
21
22 func (e Error) Error() string {
23 return "mssql: " + e.Message
24 }
25
26 // SQLErrorNumber returns the SQL Server error number.
27 func (e Error) SQLErrorNumber() int32 {
28 return e.Number
29 }
30
31 func (e Error) SQLErrorState() uint8 {
32 return e.State
33 }
34
35 func (e Error) SQLErrorClass() uint8 {
36 return e.Class
37 }
38
39 func (e Error) SQLErrorMessage() string {
40 return e.Message
41 }
42
43 func (e Error) SQLErrorServerName() string {
44 return e.ServerName
45 }
46
47 func (e Error) SQLErrorProcName() string {
48 return e.ProcName
49 }
50
51 func (e Error) SQLErrorLineNo() int32 {
52 return e.LineNo
53 }
54
55 type StreamError struct {
56 Message string
57 }
58
59 func (e StreamError) Error() string {
60 return e.Message
61 }
62
63 func streamErrorf(format string, v ...interface{}) StreamError {
64 return StreamError{"Invalid TDS stream: " + fmt.Sprintf(format, v...)}
65 }
66
67 func badStreamPanic(err error) {
68 panic(err)
69 }
70
71 func badStreamPanicf(format string, v ...interface{}) {
72 panic(streamErrorf(format, v...))
73 }