All platforms support exceptions now, so removed the test and use of

epicsThrow macro.
This commit is contained in:
Andrew Johnson
2001-02-17 04:37:48 +00:00
parent 958890ea64
commit e04c8fdd47
2 changed files with 9 additions and 46 deletions

View File

@@ -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<exc>(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 <string>
// If <T> 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 <string>
};
// 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) { ... }
*/