Exceptions.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4  Sonic Visualiser
5  An audio file viewer and annotation editor.
6  Centre for Digital Music, Queen Mary, University of London.
7  This file copyright 2006 Chris Cannam.
8 
9  This program is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License as
11  published by the Free Software Foundation; either version 2 of the
12  License, or (at your option) any later version. See the file
13  COPYING included with this distribution for more information.
14 */
15 
16 #ifndef SV_EXCEPTIONS_H
17 #define SV_EXCEPTIONS_H
18 
19 #include <exception>
20 
21 #include <QString>
22 
23 #include "Debug.h"
24 
25 class FileNotFound : virtual public std::exception
26 {
27 public:
28  FileNotFound(QString file) throw();
29  virtual ~FileNotFound() throw() { }
30  const char *what() const throw() override;
31 
32 protected:
33  QString m_file;
34 };
35 
36 class FailedToOpenFile : virtual public std::exception
37 {
38 public:
39  FailedToOpenFile(QString file) throw();
40  virtual ~FailedToOpenFile() throw() { }
41  const char *what() const throw() override;
42 
43 protected:
44  QString m_file;
45 };
46 
47 class DirectoryCreationFailed : virtual public std::exception
48 {
49 public:
50  DirectoryCreationFailed(QString directory) throw();
51  virtual ~DirectoryCreationFailed() throw() { }
52  const char *what() const throw() override;
53 
54 protected:
55  QString m_directory;
56 };
57 
58 class FileReadFailed : virtual public std::exception
59 {
60 public:
61  FileReadFailed(QString file) throw();
62  virtual ~FileReadFailed() throw() { }
63  const char *what() const throw() override;
64 
65 protected:
66  QString m_file;
67 };
68 
69 class FileOperationFailed : virtual public std::exception
70 {
71 public:
72  FileOperationFailed(QString file, QString operation) throw();
73  virtual ~FileOperationFailed() throw() { }
74  const char *what() const throw() override;
75 
76 protected:
77  QString m_file;
78  QString m_operation;
79 };
80 
81 class InsufficientDiscSpace : virtual public std::exception
82 {
83 public:
84  InsufficientDiscSpace(QString directory,
85  size_t required, size_t available) throw();
86  InsufficientDiscSpace(QString directory) throw();
87  virtual ~InsufficientDiscSpace() throw() { }
88  const char *what() const throw() override;
89 
90  QString getDirectory() const { return m_directory; }
91  size_t getRequired() const { return m_required; }
92  size_t getAvailable() const { return m_available; }
93 
94 protected:
95  QString m_directory;
96  size_t m_required;
97  size_t m_available;
98 };
99 
100 class AllocationFailed : virtual public std::exception
101 {
102 public:
103  AllocationFailed(QString purpose) throw();
104  virtual ~AllocationFailed() throw() { }
105  const char *what() const throw() override;
106 
107 protected:
108  QString m_purpose;
109 };
110 
111 #endif
virtual ~DirectoryCreationFailed()
Definition: Exceptions.h:51
FileNotFound(QString file)
Definition: Exceptions.cpp:22
const char * what() const override
Definition: Exceptions.cpp:29
QString m_purpose
Definition: Exceptions.h:108
virtual ~FileOperationFailed()
Definition: Exceptions.h:73
size_t getRequired() const
Definition: Exceptions.h:91
QString getDirectory() const
Definition: Exceptions.h:90
virtual ~FileNotFound()
Definition: Exceptions.h:29
virtual ~FailedToOpenFile()
Definition: Exceptions.h:40
virtual ~FileReadFailed()
Definition: Exceptions.h:62
QString m_file
Definition: Exceptions.h:33
virtual ~InsufficientDiscSpace()
Definition: Exceptions.h:87
QString m_file
Definition: Exceptions.h:44
virtual ~AllocationFailed()
Definition: Exceptions.h:104
QString m_file
Definition: Exceptions.h:66
size_t getAvailable() const
Definition: Exceptions.h:92