1 /*
2 * exceptions.cpp
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 #include "exceptions.h"
24
25 // C++ includes:
26 #include <sstream>
27
28 // Generated includes:
29 #include "config.h"
30
31 // Includes from sli:
32 #include "interpret.h"
33
34 std::string
message() const35 nest::UnknownModelName::message() const
36 {
37 std::ostringstream msg;
38 msg << "/" << n_.toString() + " is not a known model name. "
39 "Please check the modeldict for a list of available models.";
40 #ifndef HAVE_GSL
41 msg << " A frequent cause for this error is that NEST was compiled "
42 "without the GNU Scientific Library, which is required for "
43 "the conductance-based neuron models.";
44 #endif
45 return msg.str();
46 }
47
48 std::string
message() const49 nest::NewModelNameExists::message() const
50 {
51 std::ostringstream msg;
52 msg << "/" << n_.toString() + " is the name of an existing model and cannot be re-used.";
53 return msg.str();
54 }
55
56 std::string
message() const57 nest::UnknownModelID::message() const
58 {
59 std::ostringstream msg;
60
61 msg << id_ << " is an invalid model ID. Probably modeldict is corrupted.";
62 return msg.str();
63 }
64
65 std::string
message() const66 nest::ModelInUse::message() const
67 {
68 std::string str = "Model " + modelname_ + " is in use and cannot be unloaded/uninstalled.";
69 return str.c_str();
70 }
71
72 std::string
message() const73 nest::UnknownSynapseType::message() const
74 {
75 std::ostringstream out;
76 if ( synapsename_.empty() )
77 {
78 out << "Synapse with id " << synapseid_ << " does not exist.";
79 }
80 else
81 {
82 out << "Synapse with name " << synapsename_ << " does not exist.";
83 }
84 return out.str();
85 }
86
87 std::string
message() const88 nest::UnknownNode::message() const
89 {
90 std::ostringstream out;
91
92 if ( id_ >= 0 )
93 {
94 out << "Node with id " << id_ << " doesn't exist.";
95 }
96 else
97 {
98 // Empty message
99 }
100
101 return out.str();
102 }
103
104 std::string
message() const105 nest::NoThreadSiblingsAvailable::message() const
106 {
107 std::ostringstream out;
108
109 if ( id_ >= 0 )
110 {
111 out << "Node with id " << id_ << " does not have thread siblings.";
112 }
113 else
114 {
115 // Empty message
116 }
117
118 return out.str();
119 }
120
121
122 std::string
message() const123 nest::LocalNodeExpected::message() const
124 {
125 std::ostringstream out;
126 out << "Node with id " << id_ << " is not a local node.";
127 return out.str();
128 }
129
130 std::string
message() const131 nest::NodeWithProxiesExpected::message() const
132 {
133 std::ostringstream out;
134 out << "Nest expected a node with proxies (eg normal model neuron),"
135 "but the node with id " << id_ << " is not a node without proxies, e.g., a device.";
136 return out.str();
137 }
138
139 std::string
message() const140 nest::UnknownReceptorType::message() const
141 {
142 std::ostringstream msg;
143
144 msg << "Receptor type " << receptor_type_ << " is not available in " << name_ << ".";
145 return msg.str();
146 }
147
148 std::string
message() const149 nest::IncompatibleReceptorType::message() const
150 {
151 std::ostringstream msg;
152
153 msg << "Receptor type " << receptor_type_ << " in " << name_ << " does not accept " << event_type_ << ".";
154 return msg.str();
155 }
156
157 std::string
message() const158 nest::UnknownPort::message() const
159 {
160 std::ostringstream out;
161 out << "Port with id " << id_ << " does not exist.";
162 return out.str();
163 }
164
165 std::string
message() const166 nest::IllegalConnection::message() const
167 {
168 if ( msg_.empty() )
169 {
170 return "Creation of connection is not possible.";
171 }
172 else
173 {
174 return "Creation of connection is not possible because:\n" + msg_;
175 }
176 }
177
178 std::string
message() const179 nest::InexistentConnection::message() const
180 {
181 if ( msg_.empty() )
182 {
183 return "Deletion of connection is not possible.";
184 }
185 else
186 {
187 return "Deletion of connection is not possible because:\n" + msg_;
188 }
189 }
190
191 std::string
message() const192 nest::UnknownThread::message() const
193 {
194 std::ostringstream out;
195 out << "Thread with id " << id_ << " is outside of range.";
196 return out.str();
197 }
198
199 std::string
message() const200 nest::BadDelay::message() const
201 {
202 std::ostringstream out;
203 out << "Delay value " << delay_ << " is invalid: " << message_;
204 return out.str();
205 }
206
207 std::string
message() const208 nest::UnexpectedEvent::message() const
209 {
210 if ( msg_.empty() )
211 {
212 return std::string(
213 "Target node cannot handle input event.\n"
214 " A common cause for this is an attempt to connect recording devices incorrectly.\n"
215 " Note that recorders such as spike recorders must be connected as\n\n"
216 " nest.Connect(neurons, spike_det)\n\n"
217 " while meters such as voltmeters must be connected as\n\n"
218 " nest.Connect(meter, neurons) " );
219 }
220 else
221 {
222 return "UnexpectedEvent: " + msg_;
223 }
224 }
225
226 std::string
message() const227 nest::UnsupportedEvent::message() const
228 {
229 return std::string(
230 "The current synapse type does not support the event type of the sender.\n"
231 " A common cause for this is a plastic synapse between a device and a neuron." );
232 }
233
234 std::string
message() const235 nest::BadProperty::message() const
236 {
237 return msg_;
238 }
239
240 std::string
message() const241 nest::BadParameter::message() const
242 {
243 return msg_;
244 }
245
246 std::string
message() const247 nest::DimensionMismatch::message() const
248 {
249 std::ostringstream out;
250
251 if ( not msg_.empty() )
252 {
253 out << msg_;
254 }
255 else if ( expected_ == -1 )
256 {
257 out << "Dimensions of two or more variables do not match.";
258 }
259 else
260 {
261 out << "Expected dimension size: " << expected_ << "\nProvided dimension size: " << provided_;
262 }
263
264 return out.str();
265 }
266
267 std::string
message() const268 nest::DistributionError::message() const
269 {
270 return std::string();
271 }
272
273 std::string
message() const274 nest::InvalidDefaultResolution::message() const
275 {
276 std::ostringstream msg;
277 msg << "The default resolution of " << Time::get_resolution() << " is not consistent with the value " << val_
278 << " of property '" << prop_.toString() << "' in model " << model_ << ".\n"
279 << "This is an internal NEST error, please report it at "
280 "https://github.com/nest/nest-simulator/issues";
281 return msg.str();
282 }
283
284 std::string
message() const285 nest::InvalidTimeInModel::message() const
286 {
287 std::ostringstream msg;
288 msg << "The time property " << prop_.toString() << " = " << val_ << " of model " << model_
289 << " is not compatible with the resolution " << Time::get_resolution() << ".\n"
290 << "Please set a compatible value with SetDefaults!";
291 return msg.str();
292 }
293
294 std::string
message() const295 nest::StepMultipleRequired::message() const
296 {
297 std::ostringstream msg;
298 msg << "The time property " << prop_.toString() << " = " << val_ << " of model " << model_
299 << " must be a multiple of the resolution " << Time::get_resolution() << ".";
300 return msg.str();
301 }
302
303 std::string
message() const304 nest::TimeMultipleRequired::message() const
305 {
306 std::ostringstream msg;
307 msg << "In model " << model_ << ", the time property " << prop_a_.toString() << " = " << val_a_
308 << " must be multiple of time property " << prop_b_.toString() << " = " << val_b_ << '.';
309 return msg.str();
310 }
311
312 #ifdef HAVE_MUSIC
313 std::string
message() const314 nest::MUSICPortUnconnected::message() const
315 {
316 std::ostringstream msg;
317 msg << "Cannot use instance of model " << model_ << " because the MUSIC port " << portname_ << " is unconnected.";
318 return msg.str();
319 }
320
321 std::string
message() const322 nest::MUSICPortHasNoWidth::message() const
323 {
324 std::ostringstream msg;
325 msg << "Cannot use instance of model " << model_ << " because the MUSIC port " << portname_
326 << " has no width specified in configuration file.";
327 return msg.str();
328 }
329
330 std::string
message() const331 nest::MUSICPortAlreadyPublished::message() const
332 {
333 std::ostringstream msg;
334 msg << "The instance of model " << model_ << " cannot change the MUSIC port / establish connections " << portname_
335 << " since it is already published.";
336 return msg.str();
337 }
338
339 std::string
message() const340 nest::MUSICSimulationHasRun::message() const
341 {
342 std::ostringstream msg;
343 msg << "The instance of model " << model_ << " won't work, since the simulation has already been running";
344 return msg.str();
345 }
346
347 std::string
message() const348 nest::MUSICChannelUnknown::message() const
349 {
350 std::ostringstream msg;
351 msg << "The port " << portname_ << " cannot be mapped in " << model_ << " because the channel " << channel_
352 << " does not exists.";
353 return msg.str();
354 }
355
356 std::string
message() const357 nest::MUSICPortUnknown::message() const
358 {
359 std::ostringstream msg;
360 msg << "The port " << portname_ << " does not exist.";
361 return msg.str();
362 }
363
364
365 std::string
message() const366 nest::MUSICChannelAlreadyMapped::message() const
367 {
368 std::ostringstream msg;
369 msg << "The channel " << channel_ << " of port " << portname_ << " has already be mapped to another proxy in "
370 << model_;
371 return msg.str();
372 }
373 #endif
374
375 #ifdef HAVE_MPI
376 std::string
message() const377 nest::MPIPortsFileUnknown::message() const
378 {
379 std::ostringstream msg;
380 msg << "The node with ID " << node_id_ << " requires a label,"
381 << " which specifies the folder with files containing the MPI ports";
382 return msg.str();
383 }
384 #endif
385
386 std::string
message() const387 nest::GSLSolverFailure::message() const
388 {
389 std::ostringstream msg;
390 msg << "In model " << model_ << ", the GSL solver "
391 << "returned with exit status " << status_ << ".\n"
392 << "Please make sure you have installed a recent "
393 << "GSL version (> gsl-1.10).";
394 return msg.str();
395 }
396
397 std::string
message() const398 nest::NumericalInstability::message() const
399 {
400 std::ostringstream msg;
401 msg << "NEST detected a numerical instability while "
402 << "updating " << model_ << ".";
403 return msg.str();
404 }
405
406 std::string
message() const407 nest::UnmatchedSteps::message() const
408 {
409 std::ostringstream msg;
410 msg << "Steps for backend device don't match NEST steps: "
411 << "steps expected: " << total_steps_ << " "
412 << "steps executed: " << current_step_ << ".";
413 return msg.str();
414 }
415
416 std::string
message() const417 nest::BackendPrepared::message() const
418 {
419 std::ostringstream msg;
420 msg << "Backend " << backend_ << " may not be prepare()'d multiple times.";
421 return msg.str();
422 }
423
424 std::string
message() const425 nest::BackendNotPrepared::message() const
426 {
427 std::ostringstream msg;
428 msg << "Backend " << backend_ << " may not be cleanup()'d without preparation (multiple cleanups?).";
429 return msg.str();
430 }
431
432 std::string
message() const433 nest::KeyError::message() const
434 {
435 std::ostringstream msg;
436 msg << "Key '" << key_.toString() << "' not found in map."
437 << "Error encountered with map type: '" << map_type_ << "'"
438 << " when applying operation: '" << map_op_ << "'";
439 return msg.str();
440 }
441
442 std::string
message() const443 nest::InternalError::message() const
444 {
445 return msg_;
446 }
447
448 std::string
message() const449 nest::LayerExpected::message() const
450 {
451 return std::string();
452 }
453
454 std::string
message() const455 nest::LayerNodeExpected::message() const
456 {
457 return std::string();
458 }
459