ReflectedException.h
// ReflectedException.h
//
// Author David Barrett-Lennard
// (C)opyright Cedanet Pty Ltd 2007
@import "IObject.h"
#include "Ceda/cxUtils/IException.h"
#include "Ceda/cxUtils/xostream.h"
#include "Ceda/cxUtils/xstring.h"
#include "Ceda/cxUtils/BasicTypes.h"
namespace ceda
{
/*
Exceptions need to be reflected so that when a language like Python calls a reflected function,
any exception thrown on the C++ side can be caught and re-thrown on the Python side. Exception
classes need to be reflected to give Python access to information about what error occurred.
We want to support the conventional approach of throwing C++ exceptions by value and catching by
reference. Unfortunately it is not possible to throw an exception that implements IObject, and
catch it using a ptr<IObject> - because that would need special support from the C++ compiler.
To allow for reflection of exceptions, we require exception classes to inherit from the following
base exception class.
*/
struct IReflectedException : public IException
{
virtual const ReflectedClass& GetReflectedClass() const = 0;
};
/*
$struct+ TypeException final <<os>> : public IReflectedException
{
TypeException(ConstStringZ message) : Message(message) {}
virtual void Write(xostream& os) const;
virtual const ReflectedClass& GetReflectedClass() const;
$string8 Message;
};
*/
$struct+ UnsupportedException final <<os>> : public IReflectedException
{
UnsupportedException(ConstStringZ message) : Message(message) {}
virtual void Write(xostream& os) const;
virtual const ReflectedClass& GetReflectedClass() const;
$string8 Message;
};
$struct+ CedaSystemException final <<os>> : public IReflectedException
{
CedaSystemException(ConstStringZ message) : Message(message) {}
virtual void Write(xostream& os) const;
virtual const ReflectedClass& GetReflectedClass() const;
$string8 Message;
};
$struct+ AssertionException final <<os>> : public IReflectedException
{
AssertionException(ConstStringZ message) : Message(message) {}
virtual void Write(xostream& os) const;
virtual const ReflectedClass& GetReflectedClass() const;
$string8 Message;
};
} // namespace ceda