From e04c8fdd4782113d15ad6918dc5a8894ba80dc6b Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Sat, 17 Feb 2001 04:37:48 +0000 Subject: [PATCH] All platforms support exceptions now, so removed the test and use of epicsThrow macro. --- src/libCom/cppStd/epicsExcept.h | 43 +++------------------------------ src/libCom/cppStd/epicsList.h | 12 ++++----- 2 files changed, 9 insertions(+), 46 deletions(-) diff --git a/src/libCom/cppStd/epicsExcept.h b/src/libCom/cppStd/epicsExcept.h index 55b290804..fd463c888 100644 --- a/src/libCom/cppStd/epicsExcept.h +++ b/src/libCom/cppStd/epicsExcept.h @@ -5,31 +5,13 @@ #ifndef __EPICS_EXCEPT_H__ #define __EPICS_EXCEPT_H__ -#include "errlog.h" -#include "cantProceed.h" - -#ifdef noExceptionsFromCXX - -// In the absence of exception support, the epicsThrow macros map -// to functions that output all the info and call cantProceed() - -#define epicsThrow(exc, msg) \ - cantThrow(#exc, msg) -#define epicsThrowHere(exc, msg) \ - cantThrow(#exc, msg, __FILE__, __LINE__) - -#else // noExceptionsFromCXX - -// With exception support, one base class holds location information -// and the first macro argument names the standard exception class - +// Don't use epicsThrow, it's no longer needed and will disappear soon #define epicsThrow(exc, msg) \ throw exc(msg) + #define epicsThrowHere(exc, msg) \ throw locationException(msg, __FILE__, __LINE__) -#endif // noExceptionsFromCXX - class sourceLocation { public: sourceLocation (const char *fileName, int lineNumber); @@ -46,30 +28,11 @@ class locationException : public T, public sourceLocation { public: locationException(const char *msg, const char *fileName, int lineNumber); // NB: In standard exception classes the msg argument is a string& - // I use char* here to avoid having to include - // If will always be derived from std::exception then - // locationException could provide a version of what() as well: - // virtual const char* what() const; - // NB: Constructing that string is tricky, as it needs storage in - // the locationException class to hold it. + // I've used const char* here to avoid having to include }; -// cantThrow functions -inline void cantThrow(const char *exc, const char *msg) { - errlogPrintf("cantThrow: %s exception - %s\n", exc, msg); - cantProceed("C++ exceptions not supported on this platform"); -} - -inline void cantThrow(const char *exc, const char *msg, - const char *file, int line) { - errlogPrintf("cantThrow: %s exception at %s:%d - %s\n", exc, file, line, msg); - cantProceed("C++ exceptions not supported on this platform"); -} - - /* Examples: - * if (x<0) epicsThrow(STD_ invalid_argument, "myfunc: x<0"); * if (status) epicsThrowHere(STD_ logic_error, "failed!"); * try { ... } catch(sourceLocation& where) { ... } */ diff --git a/src/libCom/cppStd/epicsList.h b/src/libCom/cppStd/epicsList.h index 711102691..867eec2b1 100644 --- a/src/libCom/cppStd/epicsList.h +++ b/src/libCom/cppStd/epicsList.h @@ -197,28 +197,28 @@ inline epicsList::size_type epicsList::size() const { template inline T epicsList::front() { if (empty()) - epicsThrow(STD_ logic_error, "list::front: list empty"); + throw STD_ logic_error("list::front: list empty"); return static_cast(_head.next()->payload); } template inline const T epicsList::front() const { if (empty()) - epicsThrow(STD_ logic_error, "list::front: list empty"); + throw STD_ logic_error("list::front: list empty"); return static_cast(_head.next()->payload); } template inline T epicsList::back() { if (empty()) - epicsThrow(STD_ logic_error, "list::back: list empty"); + throw STD_ logic_error("list::back: list empty"); return static_cast(_head.prev()->payload); } template inline const T epicsList::back() const { if (empty()) - epicsThrow(STD_ logic_error, "list::back: list empty"); + throw STD_ logic_error("list::back: list empty"); return static_cast(_head.prev()->payload); } @@ -233,7 +233,7 @@ inline void epicsList::push_front(const T x) { template inline void epicsList::pop_front() { if (empty()) - epicsThrow(STD_ logic_error, "list::pop_front: list empty"); + throw STD_ logic_error("list::pop_front: list empty"); epicsListNode* node = _head.next(); node->unlink(); _count--; @@ -251,7 +251,7 @@ inline void epicsList::push_back(const T x) { template inline void epicsList::pop_back() { if (empty()) - epicsThrow(STD_ logic_error, "list::pop_back: list empty"); + throw STD_ logic_error("list::pop_back: list empty"); epicsListNode* node = _head.prev(); node->unlink(); _count--;