-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsli_exceptions.cpp
157 lines (138 loc) · 2.93 KB
/
sli_exceptions.cpp
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/*
* sliexceptions.cc
*
* This file is part of NEST
*
* Copyright (C) 2004 by
* The NEST Initiative
*
* See the file AUTHORS for details.
*
* Permission is granted to compile and modify
* this file for non-commercial use.
* See the file LICENSE for details.
*
*/
#include "config.h"
#include "sli_exceptions.h"
#include "sli_interpreter.h"
#include <sstream>
namespace sli3
{
std::string InvalidToken::message()
{
return "Token needs an valid pointer to a SLIType object.";
}
std::string SyntaxError::message()
{
return "The parser encountered some unknown characters.";
}
std::string DivisionByZero::message()
{
return "You cannot divide by zero.";
}
std::string TypeMismatch::message()
{
if (!provided_.empty() && !expected_.empty())
return "Expected datatype: " + expected_ + "\nProvided datatype: " + provided_;
else if (!expected_.empty())
return "Expected datatype: " + expected_;
else
return "The expected datatype is unknown in the current context.";
}
std::string RangeCheck::message()
{
if(size_ > 0)
{
std::ostringstream out;
out << "Array with length " << size_ << " expected.";
return out.str();
}
else
{
// Empty message.
// Added due to incorrect use of RangeCheck
// in nestmodule.cpp
return std::string();
}
}
std::string ArgumentType::message()
{
std::ostringstream out;
out << "The type of";
if(where)
{
out <<" the ";
if(where==1)
out << "first";
else if(where==2)
out << "second";
else if(where==3)
out <<"third";
else
out << where << "th";
out << " parameter";
}
else
out << " one or more parameters";
out <<" did not match the argument(s) of this function.";
return out.str();
}
std::string UndefinedName::message()
{
return "Key '/"+name_ + "' does not exist in dictionary.";
}
std::string EntryTypeMismatch::message()
{
return "Expected datatype: " + expected_ + "\nProvided datatype: "
+ provided_;
}
std::string StackUnderflow::message()
{
std::ostringstream out;
if(needed)
{
out << "Command needs (at least) "<< needed << " argument(s)";
if(given)
out << ", but the stack has only " << given;
out <<".";
}
else
{
out << "Command needs more arguments";
if(given)
out << "than "<< given;
out <<".";
}
return out.str();
}
std::string IOError::message()
{
return std::string();
}
std::string SystemSignal::message()
{
std::ostringstream out;
out << "The operation was interrupted by the system signal " << signal_ <<".";
return out.str();
}
std::string UnaccessedDictionaryEntry::message()
{
return "Unused dictionary items: " + msg_;
}
std::string DynamicModuleManagementError::message()
{
if(msg_.empty())
{
return "Unloading of dynamic modules is not implemented yet.";
}
else
{
return msg_;
}
}
std::string NamingConflict::message()
{
return msg_;
}
}