![]() |
The Simons
|
00001 00002 // 00003 // SCL : Simons Component Library 00004 // 00006 // 00007 // Filename: Exception.h 00008 // Contents: Exception class 00009 // Author: Anthony J H Simons 00010 // Revised: 24 March 2006 00011 00012 // This software is distributed free in the hope that others will 00013 // find it useful. However, it comes WITHOUT ANY WARRANTY. No 00014 // liability can be accepted for software failure, merchantability 00015 // or fitness for a particular purpose. You can redistribute this 00016 // software in its original form, or in a modified form, provided 00017 // that this disclaimer is retained in the file banner. 00018 00019 #ifndef SCL_EXCEPTION 00020 #define SCL_EXCEPTION 00021 00022 #include "Object.h" // Include my superclass type 00023 #include "ExceptionID.h" // Include my pointer type 00024 00025 #include "StringID.h" // Depend on the pointer types 00026 #include "OutputID.h" 00027 00062 00063 class Exception : public Object { 00064 protected: 00065 ObjectID failedObject; 00066 StringID errorMessage; 00067 ExceptionID priorException; 00068 Exception(const Exception&); 00069 public: 00070 Exception(); 00071 virtual ~Exception(); 00072 Exception(ObjectID, StringID); 00073 virtual ObjectID clone() const; 00074 ObjectID object() const; 00075 StringID message() const; 00076 Void causedBy(ExceptionID); 00077 ExceptionID cause() const; 00078 Void report() const; 00079 Void reportOn(OutputID) const; 00080 }; 00081 00082 00084 00087 inline ObjectID Exception::object() const { return failedObject; } 00088 00091 inline StringID Exception::message() const { return errorMessage; } 00092 00095 inline ExceptionID Exception::cause() const { return priorException; } 00096 00097 00099 00102 inline ExceptionID::ExceptionID() {} 00103 00105 inline ExceptionID::~ExceptionID() {} 00106 00110 inline ExceptionID::ExceptionID(const Null* null) : 00111 ObjectID(null) {} 00112 00116 inline ExceptionID::ExceptionID(const Exception* exception) : 00117 ObjectID(exception) {} 00118 00122 inline ExceptionID::ExceptionID(const ExceptionID& pointer) : 00123 ObjectID(pointer) {} 00124 00128 inline ExceptionID& ExceptionID::operator=(const Exception* exception) { 00129 assign(exception); 00130 return *this; 00131 } 00132 00137 inline ExceptionID& ExceptionID::operator=(const ExceptionID& pointer) { 00138 assign(pointer); 00139 return *this; 00140 } 00141 00142 #endif 00143