|
6 | 6 |
|
7 | 7 | namespace Microsoft.Data.SqlClient
|
8 | 8 | {
|
9 |
| - /// <include file='..\..\..\..\..\..\..\doc\snippets\Microsoft.Data.SqlClient\SqlError.xml' path='docs/members[@name="SqlError"]/SqlError/*' /> |
| 9 | + /// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlError.xml' path='docs/members[@name="SqlError"]/SqlError/*' /> |
10 | 10 | [Serializable]
|
11 | 11 | public sealed class SqlError
|
12 | 12 | {
|
13 |
| - |
14 | 13 | // bug fix - MDAC 48965 - missing source of exception
|
15 |
| - private string source = TdsEnums.SQL_PROVIDER_NAME; |
16 |
| - private int number; |
17 |
| - private byte state; |
18 |
| - private byte errorClass; |
19 |
| - [System.Runtime.Serialization.OptionalFieldAttribute(VersionAdded = 2)] |
20 |
| - private string server; |
21 |
| - private string message; |
22 |
| - private string procedure; |
23 |
| - private int lineNumber; |
24 |
| - [System.Runtime.Serialization.OptionalFieldAttribute(VersionAdded = 4)] |
25 |
| - private int win32ErrorCode; |
| 14 | + private readonly string _source = TdsEnums.SQL_PROVIDER_NAME; |
| 15 | + private readonly int _number; |
| 16 | + private readonly byte _state; |
| 17 | + private readonly byte _errorClass; |
| 18 | + [System.Runtime.Serialization.OptionalField(VersionAdded = 2)] |
| 19 | + private readonly string _server; |
| 20 | + private readonly string _message; |
| 21 | + private readonly string _procedure; |
| 22 | + private readonly int _lineNumber; |
| 23 | + [System.Runtime.Serialization.OptionalField(VersionAdded = 4)] |
| 24 | + private readonly int _win32ErrorCode; |
26 | 25 |
|
27 | 26 | internal SqlError(int infoNumber, byte errorState, byte errorClass, string server, string errorMessage, string procedure, int lineNumber, uint win32ErrorCode)
|
28 | 27 | : this(infoNumber, errorState, errorClass, server, errorMessage, procedure, lineNumber)
|
29 | 28 | {
|
30 |
| - this.win32ErrorCode = (int)win32ErrorCode; |
| 29 | + _win32ErrorCode = (int)win32ErrorCode; |
31 | 30 | }
|
32 | 31 |
|
33 | 32 | internal SqlError(int infoNumber, byte errorState, byte errorClass, string server, string errorMessage, string procedure, int lineNumber)
|
34 | 33 | {
|
35 |
| - this.number = infoNumber; |
36 |
| - this.state = errorState; |
37 |
| - this.errorClass = errorClass; |
38 |
| - this.server = server; |
39 |
| - this.message = errorMessage; |
40 |
| - this.procedure = procedure; |
41 |
| - this.lineNumber = lineNumber; |
| 34 | + _number = infoNumber; |
| 35 | + _state = errorState; |
| 36 | + _errorClass = errorClass; |
| 37 | + _server = server; |
| 38 | + _message = errorMessage; |
| 39 | + _procedure = procedure; |
| 40 | + _lineNumber = lineNumber; |
42 | 41 | if (errorClass != 0)
|
43 | 42 | {
|
44 | 43 | SqlClientEventSource.Log.TraceEvent("<sc.SqlError.SqlError|ERR> infoNumber={0}, errorState={1}, errorClass={2}, errorMessage='{3}', procedure='{4}', lineNumber={5}", infoNumber, (int)errorState, (int)errorClass, errorMessage, procedure ?? "None", (int)lineNumber);
|
45 | 44 | }
|
46 |
| - this.win32ErrorCode = 0; |
| 45 | + _win32ErrorCode = 0; |
47 | 46 | }
|
48 | 47 |
|
49 |
| - /// <include file='..\..\..\..\..\..\..\doc\snippets\Microsoft.Data.SqlClient\SqlError.xml' path='docs/members[@name="SqlError"]/ToString/*' /> |
| 48 | + /// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlError.xml' path='docs/members[@name="SqlError"]/ToString/*' /> |
50 | 49 | // bug fix - MDAC #49280 - SqlError does not implement ToString();
|
51 | 50 | // I did not include an exception stack because the correct exception stack is only available
|
52 | 51 | // on SqlException, and to obtain that the SqlError would have to have backpointers all the
|
53 | 52 | // way back to SqlException. If the user needs a call stack, they can obtain it on SqlException.
|
54 | 53 | public override string ToString()
|
55 | 54 | {
|
56 |
| - //return this.GetType().ToString() + ": " + this.message; |
57 |
| - return typeof(SqlError).ToString() + ": " + this.message; // since this is sealed so we can change GetType to typeof |
| 55 | + //return GetType().ToString() + ": " + message; |
| 56 | + return typeof(SqlError).ToString() + ": " + _message; // since this is sealed so we can change GetType to typeof |
58 | 57 | }
|
59 | 58 |
|
60 |
| - /// <include file='..\..\..\..\..\..\..\doc\snippets\Microsoft.Data.SqlClient\SqlError.xml' path='docs/members[@name="SqlError"]/Source/*' /> |
| 59 | + /// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlError.xml' path='docs/members[@name="SqlError"]/Source/*' /> |
61 | 60 | // bug fix - MDAC #48965 - missing source of exception
|
62 | 61 | public string Source
|
63 | 62 | {
|
64 |
| - get { return this.source; } |
| 63 | + get { return _source; } |
65 | 64 | }
|
66 | 65 |
|
67 |
| - /// <include file='..\..\..\..\..\..\..\doc\snippets\Microsoft.Data.SqlClient\SqlError.xml' path='docs/members[@name="SqlError"]/Number/*' /> |
| 66 | + /// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlError.xml' path='docs/members[@name="SqlError"]/Number/*' /> |
68 | 67 | public int Number
|
69 | 68 | {
|
70 |
| - get { return this.number; } |
| 69 | + get { return _number; } |
71 | 70 | }
|
72 | 71 |
|
73 |
| - /// <include file='..\..\..\..\..\..\..\doc\snippets\Microsoft.Data.SqlClient\SqlError.xml' path='docs/members[@name="SqlError"]/State/*' /> |
| 72 | + /// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlError.xml' path='docs/members[@name="SqlError"]/State/*' /> |
74 | 73 | public byte State
|
75 | 74 | {
|
76 |
| - get { return this.state; } |
| 75 | + get { return _state; } |
77 | 76 | }
|
78 | 77 |
|
79 |
| - /// <include file='..\..\..\..\..\..\..\doc\snippets\Microsoft.Data.SqlClient\SqlError.xml' path='docs/members[@name="SqlError"]/Class/*' /> |
| 78 | + /// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlError.xml' path='docs/members[@name="SqlError"]/Class/*' /> |
80 | 79 | public byte Class
|
81 | 80 | {
|
82 |
| - get { return this.errorClass; } |
| 81 | + get { return _errorClass; } |
83 | 82 | }
|
84 | 83 |
|
85 |
| - /// <include file='..\..\..\..\..\..\..\doc\snippets\Microsoft.Data.SqlClient\SqlError.xml' path='docs/members[@name="SqlError"]/Server/*' /> |
| 84 | + /// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlError.xml' path='docs/members[@name="SqlError"]/Server/*' /> |
86 | 85 | public string Server
|
87 | 86 | {
|
88 |
| - get { return this.server; } |
| 87 | + get { return _server; } |
89 | 88 | }
|
90 | 89 |
|
91 |
| - /// <include file='..\..\..\..\..\..\..\doc\snippets\Microsoft.Data.SqlClient\SqlError.xml' path='docs/members[@name="SqlError"]/Message/*' /> |
| 90 | + /// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlError.xml' path='docs/members[@name="SqlError"]/Message/*' /> |
92 | 91 | public string Message
|
93 | 92 | {
|
94 |
| - get { return this.message; } |
| 93 | + get { return _message; } |
95 | 94 | }
|
96 | 95 |
|
97 |
| - /// <include file='..\..\..\..\..\..\..\doc\snippets\Microsoft.Data.SqlClient\SqlError.xml' path='docs/members[@name="SqlError"]/Procedure/*' /> |
| 96 | + /// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlError.xml' path='docs/members[@name="SqlError"]/Procedure/*' /> |
98 | 97 | public string Procedure
|
99 | 98 | {
|
100 |
| - get { return this.procedure; } |
| 99 | + get { return _procedure; } |
101 | 100 | }
|
102 | 101 |
|
103 |
| - /// <include file='..\..\..\..\..\..\..\doc\snippets\Microsoft.Data.SqlClient\SqlError.xml' path='docs/members[@name="SqlError"]/LineNumber/*' /> |
| 102 | + /// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlError.xml' path='docs/members[@name="SqlError"]/LineNumber/*' /> |
104 | 103 | public int LineNumber
|
105 | 104 | {
|
106 |
| - get { return this.lineNumber; } |
| 105 | + get { return _lineNumber; } |
107 | 106 | }
|
108 | 107 |
|
109 | 108 | internal int Win32ErrorCode
|
110 | 109 | {
|
111 |
| - get { return this.win32ErrorCode; } |
| 110 | + get { return _win32ErrorCode; } |
112 | 111 | }
|
113 | 112 | }
|
114 | 113 | }
|
0 commit comments