-
Notifications
You must be signed in to change notification settings - Fork 0
/
Error.cs
52 lines (44 loc) · 1.27 KB
/
Error.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Consulator
{
public static class Error
{
private static string _message;
private static int _location;
private static bool _isRaised;
public static bool isRaised { get { return _isRaised; } }
//TODO What about an option to list all possible errors? (Could get messy).
public static void raise(string message)
{
if (!_isRaised)
{
_message = message;
_location = -1;
_isRaised = true;
}
}
public static void raise(int location, string message)
{
if (!_isRaised)
{
_location = location;
_message = message;
_isRaised = true;
}
}
public static string get()
{
string output = "";
for (int i = 0; i < _location; ++i)
{ output += " "; }
if (_location != -1)
{ output = " " + output + '^'; }
output += '\n' + _message;
_isRaised = false;
return output;
}
}
}