-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNotificationMessageError.cs
More file actions
66 lines (62 loc) · 2.39 KB
/
NotificationMessageError.cs
File metadata and controls
66 lines (62 loc) · 2.39 KB
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
using System.Xml.Linq;
namespace SQLProcedureDependency.Message
{
public class NotificationMessageError
{
/// <summary>
/// Error number provided by sql.
/// </summary>
public string ErrorNumber { get; }
/// <summary>
/// ErrorSeverity number provided by sql.
/// </summary>
public string ErrorSeverity { get; }
/// <summary>
/// ErrorState provided by sql.
/// </summary>
public string ErrorState { get; }
/// <summary>
/// Procedure which resulted in error provided by sql.
/// </summary>
public string ErrorProcedure { get; }
/// <summary>
/// Line number provided by sql where error did occure.
/// </summary>
public string ErrorLine { get; }
/// <summary>
/// ErrorMessage provided by sql.
/// </summary>
public string ErrorMessage { get; }
/// <summary>
/// XDocument containing parsed error message.
/// </summary>
private XDocument Error { get; }
/// <summary>
/// Constructor of NotificationMessageError class which in which error data is stored.
/// </summary>
/// <param name="value"> String containing raw xml data from Sql message. </param>
public NotificationMessageError(string value) : this(XDocument.Parse(value).Root.Element("error")){ }
/// <summary>
/// Constructor of NotificationMessageError class which in which data is stored.
/// </summary>
/// <param name="xElement"> XElement containing error data from Sql message. </param>
public NotificationMessageError(XElement xElement)
{
Error = new XDocument( xElement);
ErrorNumber = xElement.Element("number").Value;
ErrorSeverity = xElement.Element("severity").Value;
ErrorState = xElement.Element("state").Value;
ErrorProcedure = xElement.Element("procedure").Value;
ErrorLine = xElement.Element("linenb").Value;
ErrorMessage = xElement.Element("message").Value;
}
/// <summary>
/// Returns raw xml data from Sql error message.
/// </summary>
/// <returns> Returns raw xml data from Sql error message. </returns>
public override string ToString()
{
return Error.Root.Value;
}
}
}