svcore  1.9
Exceptions.h
Go to the documentation of this file.
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
00002 
00003 /*
00004     Sonic Visualiser
00005     An audio file viewer and annotation editor.
00006     Centre for Digital Music, Queen Mary, University of London.
00007     This file copyright 2006 Chris Cannam.
00008     
00009     This program is free software; you can redistribute it and/or
00010     modify it under the terms of the GNU General Public License as
00011     published by the Free Software Foundation; either version 2 of the
00012     License, or (at your option) any later version.  See the file
00013     COPYING included with this distribution for more information.
00014 */
00015 
00016 #ifndef _EXCEPTIONS_H_
00017 #define _EXCEPTIONS_H_
00018 
00019 #include <exception>
00020 
00021 #include <QString>
00022 
00023 #include "Debug.h"
00024 
00025 class FileNotFound : virtual public std::exception
00026 {
00027 public:
00028     FileNotFound(QString file) throw();
00029     virtual ~FileNotFound() throw() { }
00030     virtual const char *what() const throw();
00031     
00032 protected:
00033     QString m_file;
00034 };
00035 
00036 class FailedToOpenFile : virtual public std::exception
00037 {
00038 public:
00039     FailedToOpenFile(QString file) throw();
00040     virtual ~FailedToOpenFile() throw() { }
00041     virtual const char *what() const throw();
00042     
00043 protected:
00044     QString m_file;
00045 };
00046 
00047 class DirectoryCreationFailed : virtual public std::exception
00048 {
00049 public:
00050     DirectoryCreationFailed(QString directory) throw();
00051     virtual ~DirectoryCreationFailed() throw() { }
00052     virtual const char *what() const throw();
00053     
00054 protected:
00055     QString m_directory;
00056 };
00057 
00058 class FileReadFailed : virtual public std::exception
00059 {
00060 public:
00061     FileReadFailed(QString file) throw();
00062     virtual ~FileReadFailed() throw() { }
00063     virtual const char *what() const throw();
00064 
00065 protected:
00066     QString m_file;
00067 };
00068 
00069 class FileOperationFailed : virtual public std::exception
00070 {
00071 public:
00072     FileOperationFailed(QString file, QString operation) throw();
00073     virtual ~FileOperationFailed() throw() { }
00074     virtual const char *what() const throw();
00075 
00076 protected:
00077     QString m_file;
00078     QString m_operation;
00079 };
00080 
00081 class InsufficientDiscSpace : virtual public std::exception
00082 {
00083 public:
00084     InsufficientDiscSpace(QString directory,
00085                           int required, int available) throw();
00086     InsufficientDiscSpace(QString directory) throw();
00087     virtual ~InsufficientDiscSpace() throw() { }
00088     virtual const char *what() const throw();
00089 
00090     QString getDirectory() const { return m_directory; }
00091     int getRequired() const { return m_required; }
00092     int getAvailable() const { return m_available; }
00093 
00094 protected:
00095     QString m_directory;
00096     int m_required;
00097     int m_available;
00098 };
00099 
00100 class AllocationFailed : virtual public std::exception
00101 {
00102 public:
00103     AllocationFailed(QString purpose) throw();
00104     virtual ~AllocationFailed() throw() { }
00105     virtual const char *what() const throw();
00106 
00107 protected:
00108     QString m_purpose;
00109 };
00110 
00111 #endif