Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ThingError.cs
1using System;
2using System.Text;
3
4namespace Waher.Things
5{
10 {
11 private readonly DateTime timestamp;
12 private readonly string errorMessage;
13
20 : this(Thing.NodeId, Thing.SourceId, Thing.Partition, DateTime.Now, ErrorMessage)
21 {
22 }
23
31 public ThingError(string NodeId, string SourceId, string Partition, string ErrorMessage)
32 : this(NodeId, SourceId, Partition, DateTime.Now, ErrorMessage)
33 {
34 }
35
42 public ThingError(IThingReference Thing, DateTime Timestamp, string ErrorMessage)
43 : this(Thing.NodeId, Thing.SourceId, Thing.Partition, Timestamp, ErrorMessage)
44 {
45 }
46
55 public ThingError(string NodeId, string SourceId, string Partition, DateTime Timestamp, string ErrorMessage)
56 : base(NodeId, SourceId, Partition)
57 {
58 this.timestamp = Timestamp;
59 this.errorMessage = ErrorMessage;
60 }
61
65 public DateTime Timestamp => this.timestamp;
66
70 public string ErrorMessage => this.errorMessage;
71
73 public override string ToString()
74 {
75 StringBuilder Output = new StringBuilder();
76
77 Output.Append(this.timestamp.ToString("d"));
78 Output.Append(", ");
79 Output.Append(this.timestamp.ToString("T"));
80
81 if (!string.IsNullOrEmpty(this.NodeId))
82 {
83 Output.Append(", ");
84 Output.Append(this.NodeId);
85
86 if (!string.IsNullOrEmpty(this.SourceId))
87 {
88 Output.Append(", ");
89 Output.Append(this.SourceId);
90
91 if (!string.IsNullOrEmpty(this.Partition))
92 {
93 Output.Append(", ");
94 Output.Append(this.Partition);
95 }
96 }
97 }
98
99 Output.Append(": ");
100 Output.Append(this.errorMessage);
101
102 return Output.ToString();
103 }
104 }
105}
Contains information about an error on a thing
Definition: ThingError.cs:10
ThingError(IThingReference Thing, string ErrorMessage)
Contains information about an error on a thing
Definition: ThingError.cs:19
ThingError(string NodeId, string SourceId, string Partition, string ErrorMessage)
Contains information about an error on a thing
Definition: ThingError.cs:31
DateTime Timestamp
Timestamp of error.
Definition: ThingError.cs:65
override string ToString()
Definition: ThingError.cs:73
ThingError(IThingReference Thing, DateTime Timestamp, string ErrorMessage)
Contains information about an error on a thing
Definition: ThingError.cs:42
ThingError(string NodeId, string SourceId, string Partition, DateTime Timestamp, string ErrorMessage)
Contains information about an error on a thing
Definition: ThingError.cs:55
string ErrorMessage
Error message.
Definition: ThingError.cs:70
Contains a reference to a thing
string NodeId
ID of node.
string Partition
Optional partition in which the Node ID is unique.
string SourceId
Optional ID of source containing node.
Interface for thing references.