本站源代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
1.3KB

  1. package mssql
  2. import (
  3. "fmt"
  4. )
  5. // Error represents an SQL Server error. This
  6. // type includes methods for reading the contents
  7. // of the struct, which allows calling programs
  8. // to check for specific error conditions without
  9. // having to import this package directly.
  10. type Error struct {
  11. Number int32
  12. State uint8
  13. Class uint8
  14. Message string
  15. ServerName string
  16. ProcName string
  17. LineNo int32
  18. }
  19. func (e Error) Error() string {
  20. return "mssql: " + e.Message
  21. }
  22. // SQLErrorNumber returns the SQL Server error number.
  23. func (e Error) SQLErrorNumber() int32 {
  24. return e.Number
  25. }
  26. func (e Error) SQLErrorState() uint8 {
  27. return e.State
  28. }
  29. func (e Error) SQLErrorClass() uint8 {
  30. return e.Class
  31. }
  32. func (e Error) SQLErrorMessage() string {
  33. return e.Message
  34. }
  35. func (e Error) SQLErrorServerName() string {
  36. return e.ServerName
  37. }
  38. func (e Error) SQLErrorProcName() string {
  39. return e.ProcName
  40. }
  41. func (e Error) SQLErrorLineNo() int32 {
  42. return e.LineNo
  43. }
  44. type StreamError struct {
  45. Message string
  46. }
  47. func (e StreamError) Error() string {
  48. return e.Message
  49. }
  50. func streamErrorf(format string, v ...interface{}) StreamError {
  51. return StreamError{"Invalid TDS stream: " + fmt.Sprintf(format, v...)}
  52. }
  53. func badStreamPanic(err error) {
  54. panic(err)
  55. }
  56. func badStreamPanicf(format string, v ...interface{}) {
  57. panic(streamErrorf(format, v...))
  58. }
上海开阖软件有限公司 沪ICP备12045867号-1