Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

/home/pete/Work/TSE3.svn/tse3/src/tse3/Error.h

Go to the documentation of this file.
00001 /*
00002  * @(#)Error.h 3.00 22 June 2000
00003  *
00004  * Copyright (c) 2000 Pete Goodliffe (pete@cthree.org)
00005  *
00006  * This file is part of TSE3 - the Trax Sequencer Engine version 3.00.
00007  *
00008  * This library is modifiable/redistributable under the terms of the GNU
00009  * General Public License.
00010  *
00011  * You should have received a copy of the GNU General Public License along
00012  * with this program; see the file COPYING. If not, write to the Free Software
00013  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00014  *
00015  */
00016 
00017 #ifndef TSE3_ERROR_H
00018 #define TSE3_ERROR_H
00019 
00020 #include <string>
00021 #include <exception>
00022 
00023 namespace TSE3
00024 {
00025     /**************************************************************************
00026      * General error handling declarations
00027      *************************************************************************/
00028 
00040     enum ErrorCode
00041     {
00042         // Song error codes
00043         TrackAlreadyInsertedErr,
00044 
00045         // Track error codes
00046         PartAlreadyInsertedErr,
00047         PartOverlapErr,
00048         NoPartInsertedErr,
00049 
00050         // Track and Part error codes
00051         PartTimeErr,
00052         PhraseUnparentedErr,
00053 
00054         // Phraselist error codes
00055         PhraseNameExistsErr,
00056         PhraseAlreadyInsertedErr,
00057         InvalidPhraseNameErr,
00058 
00059         // MidiFile error codes
00060         MidiFileImportErr,
00061         MidiFileExportErr,
00062 
00063         // Serializable error codes (via TSE3MDL, TSE2MDL)
00064         CouldntOpenFileErr,
00065         InvalidFileTypeErr,
00066         FileFormatErr,
00067 
00068         // MidiScheduler error codes,
00069         MidiSchedulerCreateErr,
00070 
00074         OtherErr,
00075 
00080         NoErrorCodes
00081     };
00082 
00103     class Error : public std::exception
00104     {
00105         public:
00106 
00112             Error(ErrorCode reason) : _reason(reason) {}
00113 
00114             ~Error() throw () {}
00115 
00122             ErrorCode reason() const { return _reason; }
00123 
00129             virtual const char *what() const throw();
00130 
00131         private:
00132 
00133             ErrorCode _reason;
00134     };
00135 
00143     const char *errString(ErrorCode reason);
00144 
00145     /**************************************************************************
00146      * Specific Error subclasses
00147      *************************************************************************/
00148 
00157     class MidiFileImportError : public Error
00158     {
00159         public:
00160             MidiFileImportError(std::string const &str)
00161                 : Error(MidiFileImportErr), s(str) {}
00162             ~MidiFileImportError() throw () {}
00163             const std::string &operator *() const { return s; }
00164         private:
00165             const std::string s;
00166     };
00167 
00176     class MidiFileExportError : public Error
00177     {
00178         public:
00179             MidiFileExportError(std::string const &str)
00180                 : Error(MidiFileExportErr), s(str) {}
00181             ~MidiFileExportError() throw () {}
00182             const std::string &operator *() const { return s; }
00183         private:
00184             const std::string s;
00185     };
00186 
00195     class PhraseListError : public Error
00196     {
00197         public:
00198             PhraseListError(ErrorCode rc) : Error(rc) {}
00199             ~PhraseListError() throw () {}
00200     };
00201 
00205     class SongError : public Error
00206     {
00207         public:
00208             SongError(ErrorCode rc) : Error(rc) {}
00209             ~SongError() throw () {}
00210     };
00211 
00216     class TrackError : public Error
00217     {
00218         public:
00219             TrackError(ErrorCode rc) : Error(rc) {}
00220             ~TrackError() throw () {}
00221     };
00222 
00226     class PartError : public Error
00227     {
00228         public:
00229             PartError(ErrorCode rc) : Error(rc) {}
00230             ~PartError() throw () {}
00231     };
00232 
00236     class MidiSchedulerError : public Error
00237     {
00238         public:
00239             MidiSchedulerError(ErrorCode rc) : Error(rc) {}
00240             ~MidiSchedulerError() throw () {}
00241     };
00242 
00246     class SerializableError : public Error
00247     {
00248         public:
00249             SerializableError(ErrorCode rc) : Error(rc) {}
00250             ~SerializableError() throw () {}
00251     };
00252 }
00253 
00254 #endif

Generated on Wed May 25 14:45:06 2005 for TSE3 by doxygen 1.3.2