Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
SyntaxException.cs
1using System;
2
4{
9 {
10 private readonly string script;
11 private readonly int position;
12
19 public SyntaxException(string Message, int Position, string Script)
20 : base(Append(Message, Position, Script))
21 {
22 this.position = Position;
23 this.script = Script;
24 }
25
33 public SyntaxException(string Message, int Position, string Script, Exception InnerException)
34 : base(Append(Message, Position, Script), InnerException)
35 {
36 this.position = Position;
37 this.script = Script;
38 }
39
40 private static string Append(string Message, int Position, string Script)
41 {
42 Message += "\r\n\r\n";
43
44 int Start = Math.Max(0, Position - 100);
45 int End = Math.Min(Script.Length, Position + 100);
46
47 Message += Script.Substring(Start, Position - Start) + "^-------------" + Script.Substring(Position, End - Position);
48
49 return Message;
50 }
51
55 public int Position => this.position;
56
60 public string Script => this.script;
61
62 }
63}
Base class for script exceptions.
string Script
Script expression where syntax error was detected.
SyntaxException(string Message, int Position, string Script)
Syntax error exception.
SyntaxException(string Message, int Position, string Script, Exception InnerException)
Base class for script exceptions.
int Position
Position into script where the syntax error was detected.