Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ScriptRuntimeException.cs
1using System;
2using System.Text;
3using Waher.Events;
5
7{
12 {
13 private readonly ScriptNode node;
14
20 public ScriptRuntimeException(string Message, ScriptNode Node)
21 : base(Join(Message, Node))
22 {
23 this.node = Node;
24 }
25
32 public ScriptRuntimeException(string Message, ScriptNode Node, Exception InnerException)
33 : base(Join(Message, Node), InnerException)
34 {
35 this.node = Node;
36 }
37
45 public ScriptRuntimeException(string Message, ScriptNode Node, bool RawMessage)
46 : base(RawMessage ? Message : Join(Message, Node))
47 {
48 this.node = Node;
49 }
50
59 public ScriptRuntimeException(string Message, ScriptNode Node, Exception InnerException, bool RawMessage)
60 : base(RawMessage ? Message : Join(Message, Node), InnerException)
61 {
62 this.node = Node;
63 }
64
65 private static string Join(string Message, ScriptNode Node)
66 {
67 if (Node is null)
68 return Message;
69
70 StringBuilder sb = new StringBuilder(Message);
71
72 if (!string.IsNullOrEmpty(Node.Expression.Source))
73 {
74 sb.Append(" (Source: ");
75 sb.Append(Node.Expression.Source);
76 sb.Append(')');
77 }
78
79 string s = Node.SubExpression;
80 if (s.Length > 1000)
81 s = s.Substring(0, 1000) + "...";
82
83 sb.Append("\r\n\r\n");
84 sb.Append(s);
85
86 return sb.ToString();
87 }
88
92 public ScriptNode Node => this.node;
93
97 public string Object => this.node?.Expression?.Source ?? string.Empty;
98 }
99}
Base class for script exceptions.
ScriptNode Node
Node where error occurred.
ScriptRuntimeException(string Message, ScriptNode Node)
Script runtime exception.
string Object
Object identifier related to the object.
ScriptRuntimeException(string Message, ScriptNode Node, Exception InnerException, bool RawMessage)
Script runtime exception.
ScriptRuntimeException(string Message, ScriptNode Node, bool RawMessage)
Script runtime exception.
ScriptRuntimeException(string Message, ScriptNode Node, Exception InnerException)
Script runtime exception.
string Source
Source of script, or null if not defined.
Definition: Expression.cs:212
Base class for all nodes in a parsed script tree.
Definition: ScriptNode.cs:69
string SubExpression
Sub-expression defining the node.
Definition: ScriptNode.cs:183
Expression Expression
Expression of which the node is a part.
Definition: ScriptNode.cs:177
Implement this interface on exception classes to allow the log to extract object information in corre...
Definition: IEventObject.cs:8