NEST  2.6.0,not_revisioned_source_dir@0
sliexceptions.h
Go to the documentation of this file.
1 /*
2  * sliexceptions.h
3  *
4  * This file is part of NEST.
5  *
6  * Copyright (C) 2004 The NEST Initiative
7  *
8  * NEST is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * NEST is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with NEST. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 #ifndef SLIEXCEPTIONS_H
24 #define SLIEXCEPTIONS_H
25 
26 #include <iostream>
27 #include <string>
28 #include "name.h"
29 #include <vector>
30 
31 class SLIInterpreter;
32 
33 
34 #define UNKNOWN "unknown"
35 #define UNKNOWN_NUM -1
36 
56 class SLIException: public std::exception
57 {
58  std::string what_;
59  public:
60  SLIException(char const * const what)
61  : what_(what)
62  {}
63 
64  virtual ~SLIException() throw() {};
65 
83  virtual const char * what() const throw()
84  {
85  return what_.c_str();
86  }
87 
92  virtual std::string message() = 0;
93 };
94 
101 {
102 public:
103  virtual ~InterpreterError() throw() {}
104 
105  InterpreterError(char const * const what)
106  : SLIException(what)
107  {}
108 };
109 
118 {
119  public:
120  WrappedThreadException(std::exception&);
121  virtual ~WrappedThreadException() throw() {}
122  std::string message() { return message_; }
123 
124  private:
125  std::string message_;
126 };
127 
129 {
130  public:
131  virtual ~DivisionByZero() throw() {}
132 
134  : SLIException("DivisionByZero")
135  {}
136  std::string message();
137 
138 };
139 
140 // -------------------- Type Mismatch -------------------------
147 class TypeMismatch: public InterpreterError //SLIException
148 {
149  std::string expected_;
150  std::string provided_;
151 public:
152  ~TypeMismatch() throw() {}
153 
155  InterpreterError("TypeMismatch")
156  {}
157 
158  TypeMismatch(const std::string& expectedType)
159  : InterpreterError("TypeMismatch"),
160  expected_(expectedType)
161  {}
162 
163  TypeMismatch(const std::string& expectedType, const std::string& providedType)
164  : InterpreterError("TypeMismatch"),
165  expected_(expectedType),
166  provided_(providedType)
167  {}
168 
169  std::string message();
170 };
171 
173 {
174  int signal_;
175  public:
176  ~SystemSignal() throw() {}
178  : InterpreterError("SystemSignal"),
179  signal_(s){}
180 
181  std::string message();
182 };
183 
184 // -------------------- Array Size Mismatch -------------------------
190 {
191  int size_;
192 public:
193  ~RangeCheck() throw() {}
194 
195  RangeCheck(int s = 0)
196  : InterpreterError("RangeCheck"),
197  size_(s)
198  {}
199 
200  std::string message();
201 
202 };
203 
205 {
206  int where; // Number of the parameter that was wrong.
207  public:
209  : InterpreterError("ArgumentType"),
210  where(w){}
211 
212  std::string message();
213 
214 };
215 
221 {
222  std::string msg_;
223 
224 public:
225 
228  : SLIException("BadParameterValue"),
229  msg_()
230  {}
231 
232  BadParameterValue(std::string msg)
233  : SLIException("BadParameterValue"),
234  msg_(msg)
235  {}
236 
237  ~BadParameterValue() throw () {}
238 
239  std::string message();
240 };
241 
242 // -------------------- Dict Error -------------------------
248 {
249 public:
250  virtual ~DictError() throw() {}
251 
252  DictError(char const * const)
253  : InterpreterError("DictError")
254  {}
255 };
256 
257 // -------------------- Unknown Name -------------------------
263 class UndefinedName: public DictError // was UnknownName
264 {
265  std::string name_;
266  public:
267  ~UndefinedName() throw() {}
268  UndefinedName(const std::string& name)
269  : DictError("UndefinedName"),
270  name_(name)
271  {}
272 
273  std::string message();
274 
275 };
276 
277 // -------------------- Entry Type Mismatch -------------------------
284 {
285  std::string expected_;
286  std::string provided_;
287  public:
288  ~EntryTypeMismatch() throw() {}
289  EntryTypeMismatch(const std::string& expectedType, const std::string& providedType)
290  : DictError("EntryTypeMismatch"),
291  expected_(expectedType),
292  provided_(providedType)
293  {}
294 
295  std::string message();
296 };
297 
298 // -------------------- Stack Error -------------------------
304 {
305  int needed;
306  int given;
307  public:
308  StackUnderflow(int n, int g)
309  : InterpreterError("StackUnderflow"),
310  needed(n),
311  given(g){};
312 
313  std::string message();
314 };
315 
316 
317 
318 // -------------------- I/O Error -------------------------
323 class IOError: public SLIException
324 {
325 public:
326  ~IOError() throw() {}
328  : SLIException("IOError")
329  {}
330 
331  std::string message();
332 };
333 
338 {
339  std::string msg_;
340  public:
342  //input: string with names of not accessed
343  UnaccessedDictionaryEntry(const std::string& m)
344  : DictError("UnaccessedDictionaryEntry"),
345  msg_(m) {}
346 
347  std::string message();
348 };
349 
350 
351 // ------------ Module related error --------------------------
352 
360 {
361  std::string msg_;
362  public:
364 
366  : SLIException("DynamicModuleManagementError"),
367  msg_()
368  {}
369 
371  : SLIException("DynamicModuleManagementError"),
372  msg_(msg)
373  {}
374 
375  std::string message();
376 };
377 
385 {
386  std::string msg_;
387  public:
388  ~NamingConflict() throw() {}
389  NamingConflict(const std::string& m)
390  : SLIException("NamingConflict"),
391  msg_(m)
392  {}
393 
394  std::string message();
395 };
396 
402 {
403  std::string msg_;
404  public:
405  ~NotImplemented() throw() {}
406  NotImplemented(const std::string& m)
407  : SLIException("NotImplemented"),
408  msg_(m)
409  {}
410 
411  std::string message();
412 };
413 
414 #endif
415 
Exception to be thrown if a parameter value is not acceptable.
Definition: sliexceptions.h:220
std::string provided_
Definition: sliexceptions.h:286
Exception to be thrown if a given SLI array has the wrong size.
Definition: sliexceptions.h:189
NamingConflict(const std::string &m)
Definition: sliexceptions.h:389
Base class for all SLI interpreter exceptions.
Definition: sliexceptions.h:100
const Name g("g")
Conductance.
Definition: nest_names.h:144
virtual const char * what() const
Returns the SLI error name, used by raiseerror.
Definition: sliexceptions.h:83
std::string message()
Returns a diagnostic message or empty string.
Definition: sliexceptions.cc:95
TypeMismatch(const std::string &expectedType, const std::string &providedType)
Definition: sliexceptions.h:163
Class for packaging exceptions thrown in threads.
Definition: sliexceptions.h:117
TypeMismatch()
Definition: sliexceptions.h:154
~SystemSignal()
Definition: sliexceptions.h:176
std::string msg_
Definition: sliexceptions.h:339
DynamicModuleManagementError(std::string msg)
Definition: sliexceptions.h:370
NotImplemented(const std::string &m)
Definition: sliexceptions.h:406
std::string msg_
Definition: sliexceptions.h:361
std::string message()
Returns a diagnostic message or empty string.
Definition: sliexceptions.cc:53
Exception to be thrown if a given SLI type does not match the expected type.
Definition: sliexceptions.h:147
virtual std::string message()=0
Returns a diagnostic message or empty string.
Exception to be thrown if an error occured while accessing the stack.
Definition: sliexceptions.h:303
ArgumentType(int w)
Definition: sliexceptions.h:208
~RangeCheck()
Definition: sliexceptions.h:193
std::string message()
Returns a diagnostic message or empty string.
Definition: sliexceptions.h:122
SLIException(char const *const what)
Definition: sliexceptions.h:60
std::string message()
Returns a diagnostic message or empty string.
Definition: sliexceptions.cc:70
StackUnderflow(int n, int g)
Definition: sliexceptions.h:308
Exception to be thrown if unaccessed dictionary items are found.
Definition: sliexceptions.h:337
Throw if an feature is unavailable.
Definition: sliexceptions.h:401
~IOError()
Definition: sliexceptions.h:326
std::string message()
Returns a diagnostic message or empty string.
Definition: sliexceptions.cc:133
~EntryTypeMismatch()
Definition: sliexceptions.h:288
Exception to be thrown if an error occurs while loading/unloading dynamic modules.
Definition: sliexceptions.h:359
Exception to be thrown if an error occured in an I/O operation.
Definition: sliexceptions.h:323
std::string message()
Returns a diagnostic message or empty string.
Definition: sliexceptions.cc:167
Throw if an existing name is attempted to be redefined.
Definition: sliexceptions.h:384
~TypeMismatch()
Definition: sliexceptions.h:152
WrappedThreadException(std::exception &)
Definition: sliexceptions.cc:28
virtual ~WrappedThreadException()
Definition: sliexceptions.h:121
UndefinedName(const std::string &name)
Definition: sliexceptions.h:268
std::string name_
Definition: sliexceptions.h:265
const Name w("w")
Specific to Brette & Gerstner 2005 (aeif_cond-*)
Definition: nest_names.h:343
SystemSignal(int s)
Definition: sliexceptions.h:177
Exception to be thrown if an entry referenced inside a dictionary has the wrong type.
Definition: sliexceptions.h:283
Definition: sliexceptions.h:128
BadParameterValue()
Definition: sliexceptions.h:227
std::string message_
Definition: sliexceptions.h:125
virtual ~DivisionByZero()
Definition: sliexceptions.h:131
~UnaccessedDictionaryEntry()
Definition: sliexceptions.h:341
virtual ~DictError()
Definition: sliexceptions.h:250
~NamingConflict()
Definition: sliexceptions.h:388
std::string msg_
Definition: sliexceptions.h:403
RangeCheck(int s=0)
Definition: sliexceptions.h:195
Definition: interpret.h:69
int size_
Definition: sliexceptions.h:191
std::string message()
Returns a diagnostic message or empty string.
Definition: sliexceptions.cc:150
std::string provided_
Definition: sliexceptions.h:150
UnaccessedDictionaryEntry(const std::string &m)
Definition: sliexceptions.h:343
virtual ~InterpreterError()
Definition: sliexceptions.h:103
IOError()
Definition: sliexceptions.h:327
Definition: sliexceptions.h:172
~UndefinedName()
Definition: sliexceptions.h:267
DynamicModuleManagementError()
Definition: sliexceptions.h:365
Base class for all SLI exceptions.
Definition: sliexceptions.h:56
std::string message()
Returns a diagnostic message or empty string.
Definition: sliexceptions.cc:162
Base Class for all SLI errors related to dictionary processing.
Definition: sliexceptions.h:247
const Name n("n")
Number of synaptic release sites (int >=0) (Tsodyks2_connection)
Definition: nest_names.h:202
std::string msg_
Definition: sliexceptions.h:386
std::string message()
Returns a diagnostic message or empty string.
Definition: sliexceptions.cc:106
BadParameterValue(std::string msg)
Definition: sliexceptions.h:232
DictError(char const *const)
Definition: sliexceptions.h:252
TypeMismatch(const std::string &expectedType)
Definition: sliexceptions.h:158
virtual ~SLIException()
Definition: sliexceptions.h:64
std::string msg_
Definition: sliexceptions.h:222
Exception to be thrown if an entry referenced inside a dictionary does not exist. ...
Definition: sliexceptions.h:263
std::string message()
Returns a diagnostic message or empty string.
Definition: sliexceptions.cc:112
int needed
Definition: sliexceptions.h:305
Definition: sliexceptions.h:204
~DynamicModuleManagementError()
Definition: sliexceptions.h:363
std::string message()
Returns a diagnostic message or empty string.
Definition: sliexceptions.cc:38
int given
Definition: sliexceptions.h:306
std::string message()
Returns a diagnostic message or empty string.
Definition: sliexceptions.cc:101
std::string what_
Definition: sliexceptions.h:58
~NotImplemented()
Definition: sliexceptions.h:405
InterpreterError(char const *const what)
Definition: sliexceptions.h:105
std::string expected_
Definition: sliexceptions.h:149
std::string message()
Returns a diagnostic message or empty string.
Definition: sliexceptions.cc:138
DivisionByZero()
Definition: sliexceptions.h:133
int where
Definition: sliexceptions.h:206
~BadParameterValue()
Definition: sliexceptions.h:237
std::string message()
Returns a diagnostic message or empty string.
Definition: sliexceptions.cc:43
std::string expected_
Definition: sliexceptions.h:285
std::string message()
Returns a diagnostic message or empty string.
Definition: sliexceptions.cc:145
int signal_
Definition: sliexceptions.h:174
EntryTypeMismatch(const std::string &expectedType, const std::string &providedType)
Definition: sliexceptions.h:289