Director exceptions now derive from std::exception

This commit is contained in:
William S Fulton 2014-01-20 19:40:52 +00:00
commit cc650e692e
10 changed files with 104 additions and 73 deletions

View file

@ -9,6 +9,7 @@
#include <iostream>
#endif
#include <string>
#include <exception>
namespace Swig {
@ -17,28 +18,25 @@ namespace Swig {
};
// Base class for director exceptions.
class DirectorException {
class DirectorException : public std::exception {
protected:
std::string swig_msg;
public:
DirectorException(const char *msg) : swig_msg(msg) {
}
DirectorException(const std::string &msg) : swig_msg(msg) {
}
const std::string& what() const {
return swig_msg;
virtual ~DirectorException() throw() {
}
virtual ~DirectorException() {
const char *what() const throw() {
return swig_msg.c_str();
}
};
// Exception which is thrown when attempting to call a pure virtual method
// from D code thorugh the director layer.
class DirectorPureVirtualException : public Swig::DirectorException {
// from D code through the director layer.
class DirectorPureVirtualException : public DirectorException {
public:
DirectorPureVirtualException(const char *msg) : DirectorException(std::string("Attempted to invoke pure virtual method ") + msg) {
}