Skip to content

Commit d85f7dc

Browse files
authored
Merge pull request #61 from linas/silent
Add yet another exception type.
2 parents 2b71848 + e06bdda commit d85f7dc

File tree

2 files changed

+58
-45
lines changed

2 files changed

+58
-45
lines changed

opencog/util/exceptions.cc

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -308,27 +308,3 @@ AssertionException::AssertionException(const char* fmt, va_list ap)
308308
set_message(buf);
309309
opencog::logger().error("%s", buf);
310310
}
311-
312-
/*
313-
* ----------------------------------------------------------------------
314-
* DeleteException class
315-
* ----------------------------------------------------------------------
316-
*/
317-
DeleteException::DeleteException(void)
318-
{}
319-
320-
/*
321-
* ----------------------------------------------------------------------
322-
* NotEvaluatableException class
323-
* ----------------------------------------------------------------------
324-
*/
325-
NotEvaluatableException::NotEvaluatableException(void)
326-
{}
327-
328-
/*
329-
* ----------------------------------------------------------------------
330-
* TypeCheckException class
331-
* ----------------------------------------------------------------------
332-
*/
333-
TypeCheckException::TypeCheckException(void)
334-
{}

opencog/util/exceptions.h

Lines changed: 58 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -272,76 +272,113 @@ class AssertionException : public StandardException
272272
AssertionException(const char* fmt, va_list ap);
273273
};
274274

275+
/* ---------------------------------------------------------------- */
275276
/**
276-
* Exception to be called when the searched item was not found
277+
* Base class for exceptions that don't write to the error log.
278+
*
279+
* These exceptions will not log an error when thrown, because the
280+
* exception is thrown during normal processing, and is not an error.
281+
*/
282+
class SilentException : public RuntimeException
283+
{
284+
public:
285+
/**
286+
* Constructor
287+
* Nothing to be logged; this simply breaks us out of inner loops.
288+
*/
289+
SilentException(void) {}
290+
291+
}; // SilentException
292+
293+
/**
294+
* Exception thrown when the DeleteLink executes.
277295
*
278296
* This exception will not log an error when thrown, because the
279-
* error must be handled inside the code.
297+
* exception is thrown during normal processing, and is not an error.
280298
*/
281-
class NotFoundException : public StandardException
299+
class DeleteException : public SilentException
282300
{
283301
public:
284302
/**
285303
* Constructor
286-
*
287-
* @param Trace information (filename:line-number). Use TRACE_INFO
288-
* macro.
289-
* @param Exception message in printf standard format.
304+
* Nothing to be logged; this simply breaks us out of inner loops.
290305
*/
291-
NotFoundException(const char*, const char*, ...);
306+
DeleteException(void) {}
292307

293-
}; // NotFoundException
308+
}; // DeleteException
294309

295310
/**
296-
* Exception thrown when an expression is not evaluatable.
311+
* Exception thrown when an expression is badly nested.
312+
* Typical usage is when QuoteLink contexts seem to be confused.
297313
*
298314
* This exception will not log an error when thrown, because the
299315
* exception is thrown during normal processing, and is not an error.
300316
*/
301-
class NotEvaluatableException : public RuntimeException
317+
class NestingException : public SilentException
302318
{
303319
public:
304320
/**
305321
* Constructor
306322
* Nothing to be logged; this simply breaks us out of inner loops.
307323
*/
308-
NotEvaluatableException(void);
324+
NestingException(void) {}
309325

310-
}; // NotEvaluatableException
326+
}; // NestingException
311327

312328
/**
313-
* Exception thrown when an expression is of the wrong type.
329+
* Exception thrown when an expression is not evaluatable.
314330
*
315331
* This exception will not log an error when thrown, because the
316332
* exception is thrown during normal processing, and is not an error.
317333
*/
318-
class TypeCheckException : public RuntimeException
334+
class NotEvaluatableException : public SilentException
319335
{
320336
public:
321337
/**
322338
* Constructor
323339
* Nothing to be logged; this simply breaks us out of inner loops.
324340
*/
325-
TypeCheckException(void);
341+
NotEvaluatableException(void) {}
326342

327-
}; // TypeCheckException
343+
}; // NotEvaluatableException
328344

329345
/**
330-
* Exception thrown when the DeleteLink executes.
346+
* Exception to be called when the searched item was not found
347+
*
348+
* This exception will not log an error when thrown, because the
349+
* error must be handled inside the code.
350+
*/
351+
class NotFoundException : public SilentException
352+
{
353+
public:
354+
/**
355+
* Constructor
356+
*
357+
* @param Trace information (filename:line-number). Use TRACE_INFO
358+
* macro.
359+
* @param Exception message in printf standard format.
360+
*/
361+
NotFoundException(void) {}
362+
NotFoundException(const char*, const char*, ...);
363+
364+
}; // NotFoundException
365+
366+
/**
367+
* Exception thrown when an expression is of the wrong type.
331368
*
332369
* This exception will not log an error when thrown, because the
333370
* exception is thrown during normal processing, and is not an error.
334371
*/
335-
class DeleteException : public RuntimeException
372+
class TypeCheckException : public SilentException
336373
{
337374
public:
338375
/**
339376
* Constructor
340377
* Nothing to be logged; this simply breaks us out of inner loops.
341378
*/
342-
DeleteException(void);
379+
TypeCheckException(void) {}
343380

344-
}; // DeleteException
381+
}; // TypeCheckException
345382

346383
inline std::ostream& operator<<(std::ostream& out,
347384
const StandardException& ex)

0 commit comments

Comments
 (0)